[Biococoa-dev] Sequence factory
Koen van der Drift
kvddrift at earthlink.net
Thu Dec 23 20:10:42 EST 2004
On Dec 23, 2004, at 7:49 PM, Alexander Griekspoor wrote:
>> Why do I need 2 classes? And I have to do this every time I use a
>> sequence, which is going to happen very often? Why could not it work
>> like NSString, NSNumber, or any other class, and have factory methods
>> built into the class itself??
>
> That was exactly my problem with this approach as well. Yet, it has
> some clear advantages, code centralization being the most important,
> but also think about caching (my favorite one is restriction enzyme
> analysis, a (shared/factory) object could initialize 600 enzymes,
> which can simply be kept around as long as you need. In contrast
> bringing this into a sequence object for instance would mean that you
> have to reinitialize the enzyme plist again and again.
> Now, coming back to your remark about the code. My proposal was (and
> still is) to add these kind of (standard apple-like) methods to the
> BCSequence class as convenience methods. You would simply call:
> mySeq=[BCSequence sequenceWithString:@"AGTAGATTTGAGGT"];
> and behind the scene this (in this case class) method would invoke:
> factory=[BCSequenceFactory sharedSequenceFactory];
> mySeq=[factory sequenceWithString:@"AGTAGATTTGAGGT"];
> The best of both worlds. The User won't notice the difference, except
> that he now has the option to choose for simplicity or to optimize
> things if needed (for instance retaining the tool object).
The original reason to put in the factory class was to have a central
object that figures out what type of sequence we're dealing with when
reading files. I agree here with Alex, his proposal is definitely a way
to move forward. I guess the factory code is still pretty new in
BioCocoa, so not all parts of it have yet been coded (wink, wink ;-).
- Koen.
More information about the Biococoa-dev
mailing list