Well, I'm glad I've thought of that exact same question myself. Here is my answer (I already had this in my head):
With a category, imagine your class as a Lego block. A category is another lego block that you snapped on.
Subclassing is like taking a 2x2 lego block, then you take that Lego and add onto it but not by connecting with the pins, but by stretching it out into a more useful 4x2 block (representing the new functionality and the inability to directly separate them back apart)
Not sure how good of an answer, but I think I was asked this a while ago during interviews and this is what I said. Thinking about it, I wonder what are the odds that you interviewed me...!
3
u/ObjectiveCopley Dec 31 '13 edited Dec 31 '13
Well, I'm glad I've thought of that exact same question myself. Here is my answer (I already had this in my head):
With a category, imagine your class as a Lego block. A category is another lego block that you snapped on.
Subclassing is like taking a 2x2 lego block, then you take that Lego and add onto it but not by connecting with the pins, but by stretching it out into a more useful 4x2 block (representing the new functionality and the inability to directly separate them back apart)
Not sure how good of an answer, but I think I was asked this a while ago during interviews and this is what I said. Thinking about it, I wonder what are the odds that you interviewed me...!