[Biojava-l] Editing SymbolLists

Thomas Down td2@sanger.ac.uk
Tue, 28 Aug 2001 21:18:21 +0100


On Tue, Aug 28, 2001 at 12:21:01PM -0700, David Waring wrote:
>
> note that there are comments in both Abstract and SimpleSymbolList stating a
> desire to make them immutable e.g. in SimpleSybmolList a comment states that
> "addSymbol is deprecated Can we make it immutable?". Is this still a desire
> of some? Should we have one SimpleSymbolList implementation, and let
> ChangeListeners determine whether it was editable or not? Is there a problem
> out there were people can accidently edit a SymbolList? If SimpleSymbolList
> were to suddenly support edit, would anything break?

No, there shouldn't be any problem with this.

Actually, SimpleSymbolList isn't used for very much any more.  It
used to be the only SymbolList implementation, but a while back,
we added ChunkedSymbolList and SubArraySymbolList, which tend
to be the default implementations used.  These are the
`read-optimized' implementations.  I think this leaves us
fairly safe to replace SimpleSymbolList with a more general-purpose
implementation (which can certainly include editability, and maybe
even some simple edit-optimizations).

Regarding the comments about immutability, casting my mind
back, I think I was the one who wrote them.  They pre-date
the BioJava ChangeEvent system (which makes programming with
mutable objects a /whole/ lot cleaner and safer).  And they
/certainly/ pre-date the current edit API.  Please disregard
them.

> I like the idea of a copy constructor that Thomas suggested. I might even go
> so far as suggest a String constructor too.
> 	seq = new EditableSymbolList(alphabet,"gaattc");

That's fine, but you might prefer to take a SymbolParser
rather than an Alphabet -- seems a little cleaner.

> It is my guess that even when a SymbolList will be edited, most of the
> activity will still involve reading, and therefore an array based
> implementation is still going to be fastest. Implementations that make
> editing faster will certainly make reading slower. Do people aggree?

Sounds reasonably to me.  Worth starting with something simple,
anyway.

Thanks for your interest in this,


    Thomas.