Version 17 (modified by peko, 16 years ago) (diff) |
---|
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<Integer> fish() {
return getBean().makeValueProp("fish", Integer.class, complextMethodToComputeFish());
} because the third argument must be a constant.
Task requirements
- Write a list with irregular uses - at least 3
- Add some checks or asserts to protect from irregular uses
- Make tests, which identify irregular uses.
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 :
- using a compilator
- using exceptions
Related
How to demo
Explain the misuses to the team
Design
- Irregular pro lib uses:
- non-pro objects should not be put in any kind of properties THAT CONTAIN the @Own annotation.
- create method of resource property should not be dependent on any property except for final properties.
- value properties that are initialized at their invocation
- should be initialized with ONLY the following:
- constant primitive types.
- immutable objects that are not going to change later.
- final references to objects.
- should not set their value by a complex code invocation:
public RwProp<Integer> fish() { return getBean().makeValueProp("fish", Integer.class, complextMethodToComputeFish()); }
- should be initialized with ONLY the following:
- 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<String> 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> dummy() { return getBean().makeValueProp("dummy", Dummy.class); } //THIS SHOULD NOT BE POSSIBLE public RwProp<String> textOfDummy() { return dummy().get().text(); } }
- Misuse detection shall be done through checks and exception throwing.
- A unit test for the 4 types of irregular use will be written.
Implementation
(Implementation results should be described and linked here (from the wiki or the repository))
Testing
Comments
(Write comments for this or later revisions here.)