• 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: Confusing problems with inheritance in Objective-C
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Confusing problems with inheritance in Objective-C


  • Subject: Re: Confusing problems with inheritance in Objective-C
  • From: Chris Hanson <email@hidden>
  • Date: Mon, 21 Jun 2004 21:12:52 -0700

On Jun 21, 2004, at 7:31 PM, Darren Ford wrote:
I've been programming in C++ for many years now, and I think the problem is probably that I haven't fully understood the Obj-C concept of inheritance and I'm trying to use my C++ knowledge to define my class. Can anyone shed any light on why I'm seeing this problem? I've attached my class definitions to the end of the email.

Another more general style critique on your code: You're creating a subclass of NSMutableDictionary, but it looks like you're doing so just to use a mutable dictionary rather than in order to create a new kind of mutable dictionary.

In such a case, it's generally better to just have a mutable dictionary that's referenced by an instance variable. That way you just have a has-a relationship rather than an is-a relationship.

This goes any time you subclass another class, particularly a class from a framework. The classic example is how I've seen some developers immediately create a subclass of some other frameworks' window class when setting up a new application. They aren't actually creating a new kind of window (a round window, or a window that runs away from the mouse) -- they're just putting stuff in the window. So they don't actually need to create that subclass.

-- Chris

--
Chris Hanson <email@hidden>
http://www.livejournal.com/users/chanson/
_______________________________________________
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: Confusing problems with inheritance in Objective-C
      • From: Darren Ford <email@hidden>
References: 
 >Confusing problems with inheritance in Objective-C (From: Darren Ford <email@hidden>)

  • Prev by Date: Re: Confusing problems with inheritance in Objective-C
  • Next by Date: Re: Value Transformers and MVC ...
  • Previous by thread: Re: Confusing problems with inheritance in Objective-C
  • Next by thread: Re: Confusing problems with inheritance in Objective-C
  • Index(es):
    • Date
    • Thread