[[BackLinksMenu]] [[TicketQuery(summary=PRO_LIB_CORE_MISUSE_DETECTION_R0, format=table, col=summary|owner|status|type|component|priority|effort|importance, rows=description|analysis_owners|analysis_reviewers|analysis_score|design_owners|design_reviewers|design_score|implementation_owners|implementation_reviewers|implementation_score|test_owners|test_reviewers|test_score|)]] = Analysis = == Overview == The aim of this task is to identify irregular uses of Properties Library that could be either frequent or hard to find. An example of irregular use is : public RwProp fish() { return getBean().makeValueProp("fish", Integer.class, complextMethodToComputeFish()); } because the third argument must be a constant. == Task requirements == 1. Write a list with irregular uses - at least 3[[BR]] 2. Add some checks or asserts to protect from irregular uses[[BR]] 3. Make tests, which identify irregular uses.[[BR]] == Task result == The result of this task should be source code == Implementation idea == Prolib is a complex library. It is easy to use it irregular . It is hard to find the irregular uses, so it must have lots of conversations between teams. There is some ways to protect from irregular uses : 1. using a compilator [[BR]] 2. using exceptions[[BR]] == Related == [wiki:PRO_LIB_CORE_COMMONS_R0] == How to demo == Explain the misuses to the team = Design = * Irregular pro lib uses: * create method of resource property should not be dependent on any property except for final properties and resource properties. * value properties that are initialized at their invocation - for example: {{{ public RwProp text() { return getBean().makeValueProp("text", String.class, "this is a string."); } }}} * should be initialized with ONLY the following: * constant primitive types or literals. * public static final things. * should not set their value by a complex code invocation: {{{ public RwProp fish() { return getBean().makeValueProp("fish", Integer.class, complextMethodToComputeFish()); } }}} * should not create new objects. {{{ public RwProp dummy() { return getBean().makeValueProp("dummy", Dummy.class, new Dummy()); } }}} * properties of objects that are alike properties of other objects should create the former instead of returning them directly: {{{ class Dummy extends BaseProObject{ public RwProp text() { return getBean().makeValueProp("text", String.class, new String("this is a string.")); } } class DummyDependent extends BaseProObject{ public DummyDependent(Dummy dummy) { dummy().set(dummy); } public RwProp dummy() { return getBean().makeValueProp("dummy", Dummy.class); } //THIS SHOULD NOT BE POSSIBLE public RwProp textOfDummy() { return dummy().get().text(); } } }}} * Misuse detection shall be done through checks and exception throwing. * create method of resource property should not be dependent on any property except for final properties - the check should be made on !ResourceProperty creation. It appears that the code is commented. It should be un-commented and things should be fixed and refactored. * value properties that are initialized at their invocation - things should be checked and exception thrown: * should check that the value is the same every time the property is got. * should check that on initializing of the property, nothing else is read. * properties of objects that are alike properties of other objects should create the former instead of returning them directly - should check in !ProObject's methods that return properties that they construct new ones instead of reusing others. The check should be done at creation. * A unit test for the 3 types of irregular use will be written. = Implementation = * done according to design - one more improper use imeplemented since it is part of another task but it is still an improper usage. See unit test for more information. * a unit test for the misuse detection - [source:trunk/sophie2-platform/modules/org.sophie2.core/src/test/java/org/sophie2/core/prolib/PropertyMisuseTest.java PropertyMisuseDetection] * chages: * [changeset:1209] * [changeset:1210] * [changeset:1236] * [changeset:1246] = Testing = = Comments = ^(Write comments for this or later revisions here.)