• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Category vs Subclass
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Category vs Subclass


  • Subject: Re: Category vs Subclass
  • From: Ondra Cada <email@hidden>
  • Date: Thu, 16 Aug 2001 21:36:05 +0200

tyler,

>>>>>> tyler (t) wrote at Thu, 16 Aug 2001 10:25:44 -0700:
t> >Very, very often. Actually, whenever
t> >
t> >(i) you don't add any property;
t> >(ii) you don't need to call any [super something];
t> >
t> >In fact, save the NSObject, NSView, and NSDocument, you *HARDLY EVER*
t> >subclass anything in Cocoa.
t>
t> Is this really true? Hmm. Guess I've been sub-classing too often (C++
t> background).

C++ _DEFINITELY_ subclass too often, that's for sure.

t> But wouldn't you add at least NSWindowController to that list?
t> And what about those cases where you want a control to draw differently,
t> wouldn't that lead you to subclass NSCell or one of it's subclasses?

Well, yeah. NSWindowController I've forgot. Sorry.

The others, well, YES, *sometimes* you need to subclass them, but the cases
are pretty rare. Heck, I've already subclassed NSApplication, NSWindow,
NSString (sic!), NSTableView, NSControl, a number of EO... classes which are
alas there not anymore, etc. Though, it was just a few times in ten-plus
years of NeXTStep/OpenStep programming.

Let's took this point of view: CAN you do it without subclassing (using
preferrably property lists, delegation and target/actions /alas we have to
forget the associations!/, or categories, or perhaps even object embedding)?
If so, and if it does not make you to do strange things, then all right!

Only if this approach would either not lead to the goal, or if it would mean
complications, only then consider subclassing. And if doing so, beware class
clusters! ;)
---
Ondra Cada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc


References: 
 >Re: Category vs Subclass (From: tyler <email@hidden>)

  • Prev by Date: Re: == nil vs. isEqual:nil
  • Next by Date: Poll.h
  • Previous by thread: Re: Category vs Subclass
  • Next by thread: Re: Category vs Subclass
  • Index(es):
    • Date
    • Thread