Re: [NEWBIE]: Categories, etc vs subclassing
Re: [NEWBIE]: Categories, etc vs subclassing
- Subject: Re: [NEWBIE]: Categories, etc vs subclassing
- From: Evan Schoenberg <email@hidden>
- Date: Wed, 20 Oct 2004 03:20:23 -0500
On Oct 20, 2004, at 3:05 AM, J Tichenor wrote:
I understand that subclassing is the most powerful way to extend a
class, but also understand from many design articles and books, that
subclassing should always come as the last step.
I disagree with those articles and books; subclassing may be, depending
on your goal, the last step... or it may be the first.
I <3 delegates. In your own classes, delegate methods make objects
infinitely more reusable, and using them where possible with any class
is better than modifying the code.
Subclassing just to wrap various methods into a single call leads to an
unnecessary maintenance burden; categories are the way to go there.
Categories can make your code significantly easier to read and
therefore to debug. Additionally, you can't mess up things which
currently work using categories, since you can't override methods. On
the other hand, you can't override methods.
If you are looking to change the way a particular method acts, or
fundamentally extend the class to do things it never could have done
before, or to add functionality to existing behavior, subclassing is,
in my opinion, the best and cleanest way to go nine times out of ten.
It's object-oriented programming at its best. It's just plain amazing
what some clever subclassing can accomplish where any other way of
addressing the problem would lead to a giant mess of code. :)
Just my first two cents on the dev list,
Evan Schoenberg
_______________________________________________
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