• 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: Subclassing best practice
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Subclassing best practice


  • Subject: Re: Subclassing best practice
  • From: David Spooner <email@hidden>
  • Date: Wed, 14 Nov 2007 12:27:09 -0700


On 14-Nov-07, at 11:34 AM, Uli Kusterer wrote:

Am 14.11.2007 um 18:39 schrieb John Stiles:
This works great. However, from a code design perspective, it seems sloppy to me. I don't like having to rely on macros.
In other languages, I could use multiple inheritance, (...) But ObjC doesn't support multiple inheritance.


There are a few cases where I used a Macro, too, but in most cases, stepping back and looking at the code again helped me find a better design that didn't need multiple inheritance:

E.g. often when I was adding members to a basic class like NSWindow, what I really wanted was to have a common base class for my window delegates (i.e. the controller), or to add these members to my model somewhere. Or sometimes, just splitting the controller into several classes helped.

I agree. I would use either the delegate or the window controller to add extra information. I've only needed to subclass window in order to allow an untitled window to become key, by overriding - canBecomeKeyWindow.


dave

 Sometimes, categories helped, too.

And also, with ObjC 2.0, one can apparently add properties to existing objects somehow. I think this came up on ObjC-Langauge a couple days ago.

Cheers,
-- M. Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Subclassing best practice (From: John Stiles <email@hidden>)
 >Re: Subclassing best practice (From: Uli Kusterer <email@hidden>)

  • Prev by Date: Re: Subclassing best practice
  • Next by Date: Re: Heads Up: Code generation bug
  • Previous by thread: Re: Subclassing best practice
  • Next by thread: Re: Subclassing best practice
  • Index(es):
    • Date
    • Thread