• 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: Window Styles
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Window Styles


  • Subject: Re: Window Styles
  • From: Rob Abernathy <email@hidden>
  • Date: Sun, 16 May 2004 01:33:14 +0100

So, basically you are saying "follow O-O principles." There isn't anything strange going on in AppKit.

Interestingly, I think the thing that led to this question is really not that great of an example of when you should subclass. Needing to subclass to set an attribute value that is present in all NSWindow instances doesn't seem appropriate to me. It just happens that this is the only clean way to do this because NSWindow requires that the style mask be set at initialization. Which, in turn, seems to be an unnecessary restriction. I can think of some pretty nice uses for being able to change this characteristic of a window dynamically (after creation).


On May 15, 2004, at 5:33 PM, Ondra Cada wrote:

Rob,

On 15.5.2004, at 17:03, j o a r wrote:

Why should you usually avoid subclassing? Do you mean in Cocoa or
AppKit? If so, why?

Developers coming to Cocoa from other OOP environments (Java, C++) are
often accustomed to rely heavily on subclassing. Cocoa is designed in a
different way, where categories (a language feature of ObjC) and
delegates (a very effective design pattern) often makes it unnecessary
to subclass most specialized classes in Cocoa.
I'm not saying that you should never subclass, but you should look for
alternatives before you do. I't often easier and more flexible not to.

Amen to that.

And, (again of course not without exceptions, but *very very often*)
subclassing tends to lead to bad MVC patterns, whilst delegation,
object embedding and message forwarding, and similar ObjC/Cocoa
technologies tend to keep MVC clean and transparent.

Therefore, unless you happen to work with a class explicitly designed
for subclassing (like, say, NSDocument or NSView), you should always
consider patterns which do not exploit subclassing first, and resort to
subclassing only if none of them proves to be useable and convenient.
---
Ondra Hada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc

[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >Re: Window Styles (From: Mark Thomas <email@hidden>)
 >Re: Window Styles (From: Jeremy Dronfield <email@hidden>)
 >Re: Window Styles (From: j o a r <email@hidden>)
 >Re: Window Styles (From: Rob Abernathy <email@hidden>)
 >Re: Window Styles (From: j o a r <email@hidden>)
 >Re: Window Styles (From: Ondra Cada <email@hidden>)

  • Prev by Date: Re: Cocoa volume knob control?
  • Next by Date: Re: One-line TextViews
  • Previous by thread: Re: Window Styles
  • Next by thread: Re: Window Styles
  • Index(es):
    • Date
    • Thread