RE: Convenience Methods
RE: Convenience Methods
- Subject: RE: Convenience Methods
- From: Jeff Laing <email@hidden>
- Date: Thu, 27 Sep 2007 09:28:35 +1000
> > The problem here is with the 'isa' part of inheritance. The definition
of
> > NSString is 'a datatype that cannot be edited'. How can NSMutableString
be
> > a *subclass* of that definition?
>
> When you are controlling the definitions, it is easy to set up a
> straw man then knock him down :-).
>
> If you define an NSString as an object which is conceptually an array
> of unicode characters, and define NSMutableString as a subclass which
> extends the capabilities to include modifying the stored characters,
> it doesn't sound nearly as distasteful.
Hey, I'm just revisiting OO-Design-102, the lecture where the prof says "who
thinks a square is a subclass of rectangle or vice versa" and then goes on
to ask you to justify your choice, and the mathematicians jump one way while
the programmers jump another...
(And, of course, NSString is *not* an array of unicode characters, thats
implementation detail :)
> The object mutability reference discusses some of the reasons why the
> Cocoa frameworks have mutable and immutable variants of objects.
That would be the document that contains the gem: "Although in theory
immutability guarantees that an object's value is stable, in practice this
guarantee isn't always assured". Comforting. It also contains the following:
"When the mutability of objects is an issue, it's best to adopt some
defensive programming practices.
-
-
- Rely on the return type for indications of mutability."
(What a shame that the NS classes don't help you out here)
I'm seriously interested in why Apple bother having such a document - is
there an expectation that in my (for example) iTunes-access-library, I would
seriously consider having ITTrack and ITMutableTrack classes? ITArtist and
ITMutableArtist?
Its a serious question. Who would include mutable and immutable classes in
the own application? Even in their own frameworks? Why doesn't the
AddressBook.framework provide ABPerson and ABMutablePerson?
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden