Hi Humberto and others!
There is a zip at
http://www.imt.liu.se/~erisu/2007/mutable_immutable.zip with a small
test (including java-code and comments) of an approach that possibly
would let us have a choice of both mutable and immutable classes and a
conversion mechanism between the two. Please have a look and comment.
There was a lot of mail discussion before this regarding arguments for
and against (im)mutability, some excerpts to start searching the mail
archives from are listed below.
Something like a summary:
http://www.openehr.org/mailarchives/ref_impl_java/msg00380.html
Discussions regarding setters - if you have mutable objects that you
want to populate piece by piece it is not enough to have validation in
the constructor as for immutable objects - am you might (e.g. in a
GUI) want to allow "invalid" states for a while and the choice _when_
(and where in a distributed system) to validate may vary depending on
system setup:
http://www.openehr.org/mailarchives/ref_impl_java/msg00327.html
Some background to the above comes from the very long thread
"Hibernate and RM" starting with...
http://www.openehr.org/mailarchives/ref_impl_java/msg00210.html
...some examples from followups in that thread regarding
(im)mutability and/or validation (others might want to highlight other
messages)...
http://www.openehr.org/mailarchives/ref_impl_java/msg00212.html (ES)
http://www.openehr.org/mailarchives/ref_impl_java/msg00221.html (TB)
http://www.openehr.org/mailarchives/ref_impl_java/msg00231.html (ES)
http://www.openehr.org/mailarchives/ref_impl_java/msg00256.html (RC)
http://www.openehr.org/mailarchives/ref_impl_java/msg00285.html (ES -
a bit of my summary)
http://www.openehr.org/mailarchives/ref_impl_java/msg00286.html (RC -
reply to the above)
http://www.openehr.org/mailarchives/ref_impl_java/msg00345.html (ES -
suggesting branch)
http://www.openehr.org/mailarchives/ref_impl_java/msg00353.html (TB -
multiple validations)
The svn branch mentioned above and that I'd recommend to use for
experimenting with changing immutable things to mutable is:
http://www.openehr.org/svn/ref_impl_java/BRANCHES/immutable-experiment/
It has not been updated recently so it's probably a good idea to start
by getting the latest changes from the main trunk in (should be fairly
easy). Last time that operation looked like this:
http://www.openehr.org/mailarchives/ref_impl_java/msg00450.html
Best regards,
Erik Sundvall
erisu@imt.liu.se http://www.imt.liu.se/~erisu/ Tel: +46-13-227579
[...] Also, may I make a "mutable experiment" (a new branch) of the RM and
AM? (This will turn my life much better...)
> Regards,
> Humberto Naves
>
On Dec 14, 2007 6:58 PM, Erik Sundvall <erisu@imt.liu.se> wrote (off-list):