Re: Class clusters - infinite loop?
Re: Class clusters - infinite loop?
- Subject: Re: Class clusters - infinite loop?
- From: Sherm Pendley <email@hidden>
- Date: Sat, 25 Jun 2005 13:23:50 -0400
On Jun 25, 2005, at 2:52 AM, email@hidden wrote:
I must ask, is a class cluster really necessary? They're the bane
of extensibility, for only an addition of some trivial
convenience. Is it not a better approach to have well-defined
subclasses, specialising in particular areas?
No, IMHO that wouldn't be better.
When the specialization is internal - that is, when BigDataHolder and
SmallDataHolder expose identical public APIs, with the only
difference being the private implementation - then using public
subclasses breaks encapsulation. It becomes the caller's
responsibility to decide which of the subclasses are more
appropriate, and to make that decision the caller would have to be
aware of internal implementation details it wouldn't otherwise need
to care about.
And what happens when you want to extend such an approach, say by
adding Tiny, Medium, and Huge subclasses? The calling code would have
to change as well, to account for not only the new subclasses but the
new criteria for deciding which subclass is appropriate. So much for
extensibility...
I'm not sure what you mean by "bane of extensibility", anyway. I've
extended NSArray and NSDictionary class clusters both ways, by adding
new behavior to the superclass with a category, and by implementing a
new data storage subclass with its own set of primitive methods. It's
not quite rocket surgery.
sherm--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden