[Biojava-l] Immutable objects and ChangeListeners
08 Jan 2001 18:22:23 +0000
I have a question re. objects designed to be immutable under all
circumstances and yet implementing Changeable.
e.g. I wanted FastaSearchResult to be immutable but also to implement
Annotatable (the search header contains a lot of fairly loosely
formatted, but worthwhile data). This means that it has to implement
I suppose I could implement the methods as stubs which do nothing.
I've seen this elsewhere in Biojava, I think. As the methods return
nothing and can't throw exceptions I guess this should work. However
is it good that someone who uses these methods (and is therefore
expecting the object to change) should be able to add/remove a
Listener? Or think that they had, when in fact nothing had happened.
As the methods are not allowed to throw exceptions, how can you
politely say "Are you sure you want to listen for changes - this
object is immutable" ?
-= Keith James - firstname.lastname@example.org - http://www.sanger.ac.uk/Users/kdj =-
The Sanger Centre, Wellcome Trust Genome Campus, Hinxton, Cambs CB10 1SA