commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Luc Maisonobe <Luc.Maison...@free.fr>
Subject Re: [math] Read-only RealVector
Date Thu, 11 Aug 2011 11:22:06 GMT
Le 11/08/2011 13:10, Sébastien Brisard a écrit :
> 2011/8/11 sebb<sebbaz@gmail.com>:
>> 2011/8/11 Sébastien Brisard<sebastien.brisard@m4x.org>:
>>> OK, this I also think would be useful. But my initial question
>>> remains, if the object I want to protect is not a RealVector, what do
>>> you think of my solution ?
>>> Sébastien
>>
>> If you create the read-only version by subclassing the writable
>> version, then you have to ensure that all mutating methods are
>> overridden.
>> If a base class is later extended to add a new mutator, the protection is lost.
> That's quite true... Didn't think of that. It pretty much ruins it, doesn't it?

You can also have a common interface without modification methods, and 
two implementations, an immutable one and a mutable one (I think this is 
how Scala containers are designed).

Luc

>
> Sebastien
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message