On Mon, May 11, 2009 at 7:12 PM, Staz . <[email protected]> wrote:
> I am not sure what Niclas would say, but to give you a quick answer
> - most likely you would want add methods
>
> setString(String newString);
> addValue(SimpleValue sv);
> removeValue(SimpleValue);
I wouldn't answer that... ;-)
What we try to promote is that state is kept very, very internal. The
less that is exposed the more it can be modified over time.
So, instead of eposing internal state and having clients change that
state, you should think of, and expose, the intentions of those
clients. So, instead of a;
public interface Bucket
{
Property<Float> waterVolume();
}
and having the client;
bucket.waterVolume().set( bucket.waterVolume().get() + 10 ) );
we want to see the equivalents of
public interface Bucket
{
Float waterVolumeInLitres();
void addLitresOfWater( float amount );
interface BucketState
{
Property<Float> waterVolumeInLitres();
}
}
If the Bucket is "immutable", then the addLitresOfWater method is just
not there.
Cheers
--
Niclas Hedhman, Software Developer
http://www.qi4j.org - New Energy for Java
I live here; http://tinyurl.com/2qq9er
I work here; http://tinyurl.com/2ymelc
I relax here; http://tinyurl.com/2cgsug
_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev