Re: exception in class derived from NSMutableDictionary
Re: exception in class derived from NSMutableDictionary
- Subject: Re: exception in class derived from NSMutableDictionary
- From: Chris Hanson <email@hidden>
- Date: Wed, 30 Jul 2003 15:27:40 -0500
On Wednesday, July 30, 2003, at 01:03 PM, Robert G Palmer Jr wrote:
One advantage to the "has-a" relationship, which is probably a good
argument to going back "has-a" is that it hides the implementation.
However, from the user's perspective, each item in the collection is
accessed via the MAC address as the key, which points back to "is-a"
because that approach to accessing (using the MAC as a key) implies a
dictionary.
Why not just use a straight dictionary then?
It looks like you're conflating two things, creating VideoSensor
objects and storing them in a collection. I'd just use a regular
NSMutableDictionary keyed by MAC address, and add a factory method to
VideoSensor that creates one given a MAC address, IP address, and
product.
Generally, I reserve subclassing for creating new kinds of objects
along is-a lines. For instance, if I needed a dictionary that always
kept its keys sorted in some natural order, I would probably create
SortedDictionary and SortedMutableDictionary subclasses. But I
wouldn't normally subclass because of the type of the objects I'm
storing.
-- Chris
--
Chris Hanson, bDistributed.com, Inc. | Email: email@hidden
Custom Mac OS X Development | Phone: +1-847-372-3955
http://bdistributed.com/ | Fax: +1-847-589-3738
http://bdistributed.com/Articles/ | Personal Email: email@hidden
_______________________________________________
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.