Re: Wisdom of overriding isEqual:
Re: Wisdom of overriding isEqual:
- Subject: Re: Wisdom of overriding isEqual:
- From: Bill Cheeseman <email@hidden>
- Date: Wed, 10 Mar 2004 20:00:07 -0500
on 2004-03-10 5:33 PM, Patrick Machielse at email@hidden wrote:
>
This is nice, since I can then look at the documentation of isEqualTo.. for
>
these classes and see how equality is implemented.
>
>
But what if a class doesn't define an isEqualTo... method? Does that mean
>
this class doesn't override NSObject's isEqual: implementation, or does it
>
indeed override isEqual:, but simply _undocumented_? Either way I can't find
>
out how equality is defined for these objects, since NSObject's
>
documentation essentially says: 'isEqual's implementation defines it's own
>
meaning'.
The existing Cocoa class reference documents certainly should say something
about -isEqual: overrides. Or, if there is an absolutely standard convention
for this in Apple's data classes -- as I suspect there is -- it might just
as well be documented in a higher-level concepts document.
As to non-Apple classes, I happen to know that there are some floating
around in public that don't handle -isEqual: properly -- because I wrote
them. My to-do list includes fixing them. I'm sure others have posted
classes that don't handle -isEqual: properly, too, since the documentation
hasn't been clear.
The consequence of this, from my point of view, is that you have to use
enumeration loops to handle things that built-in Cocoa collection class
methods would handle if -isEqual: were correctly implemented in a custom
class -- unless you do enough testing to satisfy yourself that -isEqual: is
in fact correctly implemented.
What we need -- those of us who like to write custom data classes for public
consumption -- is an "official" list of methods that every custom data class
ought to implement or override. The various existing protocols, like
NSCoding and NSCopying, are very helpful from my point of view, but there
isn't really any protocol for -isEqual:.
--
Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com
The AppleScript Sourcebook -
http://www.AppleScriptSourcebook.com
Vermont Recipes -
http://www.stepwise.com/Articles/VermontRecipes
_______________________________________________
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.