[Drawkit] [self selectedAvailableObjects] empty!??

Graham Cox graham.cox at bigpond.com
Thu Jul 17 20:59:05 PDT 2008


Hi James,

There's a quite a simple rule to use to determine if you need a  
subclass or a category:

If you need to add more data to an object (more instance variables)  
then subclass. If you only need to add methods, make a category.

I don't know if this is the same as anything in Java - I'm not at all  
familiar with it. It's not something you can do in C++ either, so as  
far as I know it may be unique to Objective-C. But it's incredibly  
useful. It avoids the need to subclass just to add a method or two  
that the original writer "forgot" or for a need that wasn't  
anticipated in the design of the object, or just to make common  
operations quicker and easier (by calling several existing methods in  
a common sequence, say). For framework creators like me, it's  
fantastic because it means that I don't have to try and anticipate  
everyone's needs to the last degree.

cheers, Graham


On 18 Jul 2008, at 1:39 pm, James Maxwell wrote:

> My subclass of DKObjectDrawingLayer does a few things, some  
> concerning selections, others concerning my "musical grid". I  
> couldn't see any direct way of doing what I needed to do, other than  
> subclassing, and it seems to be okay, for the moment... To be  
> honest, I don't really know anything about categories. I'm thinking  
> they're a bit like Interfaces in Java, but I don't really know.


More information about the Drawkit mailing list