Re: Mutable class problems
Re: Mutable class problems
- Subject: Re: Mutable class problems
- From: Michael Tsai <email@hidden>
- Date: Tue, 25 Jun 2002 11:40:08 -0400
On 6/25/02 at 5:00 PM, Ondra Cada <email@hidden> wrote:
>
On Tuesday, June 25, 2002, at 03:54 , Andy Lee wrote:
>
>
> I have a slight quibble with this class design, which is having
>
> NSMutableThing subclass from NSImmutableThing. A subclass should
>
> extend its superclass, not adopt a behavior which is expressly
>
> banned in the semantics of the superclass.
>
>
It does that, exactly. I fear you don't understand the
>
(im)mutability design completely.
I think Andy does understand it but he's troubled that it violates the
LSP:
<
http://www.dictionary.com/search?q=Liskov substitution principle>
<
http://www.brent.worden.org/tips/2000/liskovSubstitutionPrinciple.html>
I am too, though I have to admit that the current design hasn't
caused me any problems (yet). I like the Foundation design better
than the way Java does it. In Java, you can have mutable and
immutable objects at runtime but only mutable interfaces to use in
your source. (And you can only create immutable objects by wrapping
mutable ones--there's nothing like arrayByAddingObject:.) With
Foundation, at least you can use the types to communicate intent. I
doubt it's possible to do better than that in a language like ObjC
while still keeping an API that's simple to use.
Michael
--
DropDMG for Mac OS X
http://www.c-command.com/dropdmg
_______________________________________________
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.