Hey,

This is the first mail on things that we talked about at the GeekCruise. 
More to follow, but not all at once, so that each thing can get the 
attention it deserves.

Currently properties are declared by using a method in an interface, and 
the type of property can be either Property, ImmutableProperty or 
ComputedProperty. As has already been noted in some cases this makes it 
difficult to reuse property declarations, since whether they are 
immutable or not is sometimes a matter of context. If "HasName.name()" 
is part of an Entity it might be mutable, whereas the same property in a 
ValueComposite should be immutable.

To alleviate this it was suggested that we instead only have Property as 
the interface and use annotations like @Immutable and @Computed to 
denote these things. It is also suggested that metaInfo() is populated 
with the annotations of the type it represents, such as Composite, 
Entity, Property or Association.

For example, if you declare "@Immutable Property<String> name()" you can 
then do property.metaInfo(Immutable.class) and get the annotation back 
(or null). In addition to this, it is suggested that annotations are 
inherited, so that if you declare an annotation on an interface it is 
"leaked" to the methods/properties. That way you can do this:
@Immutable
interface PersonValue
{
   Property<String> name();
}
and name() would then be an immutable property. This can be refactored to:
@Immutable
interface PersonValue
   extends HasName
{}

The individual HasName interface can then be used in both mutable and 
immutable contexts.

Same reasoning then for @Computed, although it's going to be less useful 
to do the inheritance of it (maybe, although name() can actually be 
computed in some cases).

What say ye? Michael did this refactoring on my computer (not 
committed), so from an implementation point of view it seems fine.

/Rickard



_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev

Reply via email to