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

Re: Subclass


  • Subject: Re: Subclass
  • From: Marco Scheurer <email@hidden>
  • Date: Sat, 14 Jun 2003 16:40:12 +0200

On Saturday, June 14, 2003, at 10:22 AM, Sailor Quasar wrote:

On Friday, June 13, 2003, at 11:14 PM, Marco Scheurer wrote:
Is there another way to do this in Obj-C.
At runtime. You can implement these methods to send a doesNotRecognizeSelector: message. Or, there used to be a subclassResponsibility: method in NSObject, but it's not there anymore. You could create one that raises a meaningful exception and use it.

With all due respect to the Obj-C veterans on these lists, and aplogies for cross-posting to cocoa-dev, the functionality requested by the original poster of this thread is one of several minor OO bits that C++ has but Obj-C does not that I feel would be better off there:

1. As noted, enforcement of pure virtual base classes.

The enforcement looks like on paper, but is useless in practice, as this is never a cause of problems. And as described above, it *can* be enforced: at runtime instead of compile time, just like for dynamic typing. This is Objective C.

2. The ability to declare methods protected or private I'm aware it's quite possible to declare private methods as a category within the class' source file so that the selectors are not published to client code. For private methods this is fine since it prevents unwanted code from easily using them, but for protected methods it's a nusiance at best and not doable at worst.

I don't miss them since I think that private and protected are an hindrance to flexibility and reuse. To decide that a piece of code will never need to be used differently than what I know now is presumptuous. Java's final falls in the same category.

3. The ability to declare static instance vars (instance vars that are part of the class object rather than of any instance of that class). If I've missed this functionality somewhere, please tell me where it is. I generally use globals to emulate it, which I personally feel is bad style.

What's missing is real class variables (static vars are available as in plain C and often used as a workaround for class variables).

Marco Scheurer
Sen:te, Lausanne, Switzerland http://www.sente.ch
_______________________________________________
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.

  • Follow-Ups:
    • Re: Subclass
      • From: "Alastair J.Houghton" <email@hidden>
    • Re: Subclass
      • From: lbland <email@hidden>
References: 
 >Re: Subclass (From: Sailor Quasar <email@hidden>)

  • Prev by Date: Re: troubling article
  • Next by Date: Re: Toolbar item with a menu...
  • Previous by thread: Re: Subclass
  • Next by thread: Re: Subclass
  • Index(es):
    • Date
    • Thread