[Biojava-l] Lazy instantiation and the Sequence interface
David Huen
smh1008@cus.cam.ac.uk
Sat, 23 Jun 2001 20:57:30 +0100 (BST)
I'm implementing lazy instantiation and caching for Ragbag to limit
resource usage for truly large sequence assemblies and I have run into
some problems.
Since with lazy instantiation, I do not actually complete instantiation of
the delegate Sequence objects, it is possible that exceptions may arise
when methods in the Sequence interface is eventually invoked (e.g. the
sequence could not be created).
However, many of the methods do not appear to support Exceptions resumably
because there was no prospect of that arising with the current
implementations.
I can see 3 possibilities:-
1) I fully validate all input data by creating all data objects at
instantiation of a Ragbag tree. This could consume huge amounts of
resources for a large assembly and would be pointless since the cache
behaviour will result in many of these objects being destroyed almost
immediately. Instantiation of a large tree could also take a very long
time.
2) I trap all exceptions in my methods and provide a query method to find
out if an exception did occur. Failure to check could mean apps using
Ragbag as a Sequence could crash and burn. Use of Ragbag will then not be
transparent.
3) change the Sequence interface to add a throw BioException to all
methods. Sequence is widely used thru' out Biojava. Existing software
depends on this interface and will not take kindly to such a change. It
will break compilation and doesn't seem something wise to do prior to a
stable release. I could hold off the new Ragbag stuff till after the
stable release and fix this then.
Please advise.
Regards,
David Huen, Dept. of Genetics, Univ. of Cambridge.