[Biococoa-dev] Subclassing BCSequence really needed?

Koen van der Drift kvddrift at earthlink.net
Fri Oct 22 22:12:37 EDT 2004


(Trying to get some life back into the group :-D

I have been thinking a lot recently (again) if it is really needed to 
subclass BCSequence. One of the things that keeps bugging me for 
instance is the duplicated code in BCNucleotideDNA and BCNucleotideRNA 
for getting the subsequences. Somehow it doesn't seem the most 
efficient approach, and also not applying the OOP paradigms. One of the 
things that is central in OOP is trying to avoid code duplication. I 
also have been thinking a lot too to see what would be a better (if 
any) approach for these kind of situations. We could for instance put 
the code to get a range in a wrapper class. If we just use a 
BCSequence, the same code to get a range can be used for RNA, DNA, and 
Protein. Similarly, for other sequence charcteristics, or for reversing 
and translating a sequence.

But if we only use a BCSequence, how do we know if we are dealing with 
a Protein, DNA, etc? Well, we already are using the BCSequenceType 
variable, which the wrapper could check for. Or, as discussed before, 
we implement Alphabets (symbolsets) which are then used by the wrapper 
to identify the type of sequence. Both approaches will also reduce the 
need for testing each symbol if it is really part of a Protein, DNA, 

As a snippet we could use code like this to create a new DNA:

BCSymbolSet	*dnaSet	=	[[BCSymbolSet alloc] initWithCharacterSet: DNA]; 
// global

BCSequence	*myDNA	=	[[BCSequence alloc] initWithString; 
@"aaatttccctttggg] usingSymbolSet: dnaSet];

An addiitonal advantage of this approach is that when we think of a new 
cool feature to add to BioCocoa, we only have to put it in a wrapper 
class, instead of a slightly modified version in each of the subclasses 
of BCSequence. This is much easier to maintain, and also less prone to 

I know that I have brought this up before, but I think it is important 
that we discuss it a little bit more, before BioCocoa expands further.


- Koen.

More information about the Biococoa-dev mailing list