Re: Mutable class problems
Re: Mutable class problems
- Subject: Re: Mutable class problems
- From: Andy Lee <email@hidden>
- Date: Wed, 26 Jun 2002 12:14:54 -0400
At 4:32 PM +0200 6/26/02, Marco Scheurer wrote:
On Tuesday, June 25, 2002, at 05:40 pm, Michael Tsai wrote:
[...stuff about NSMutableThing inheriting from NSImmutableThing...]
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>
IMHO this is not a violation of the LSP, but a violation of the
semantic implied by the choice of names.
Right about the choice of names. Ondra had put "Immutable" in the
name of a hypothetical superclass, and that's what I was reacting to.
But if that semantic was intended, then I claim violating it *is* a
violation of the LSP. If the "Immutable" semantic was *not*
intended, then that was a horrible choice for a class name. Why
misleadingly call something Immutable when you mean
PossiblyImmutablePossiblyNot? I assumed the latter was not what
Ondra meant.
This choice of names is clearly embarassing. At least, in
Foundation, nothing qualifies the superclass names: NSMutableArray
inherits from NSArray, mutableThing is a Thing.
True, the Foundation names don't carry the false implication -- as
long as you ignore the documentation. In reality, an NSArray -- an
object legitimately pointed to by an NSArray * -- may or may not be
mutable. In the documentation, "An NSArray stores an immutable array
of objects."
On Tuesday, June 25, 2002, at 05:40 pm, Michael Tsai wrote:
I am too, though I have to admit that the current design hasn't
caused me any problems (yet).
Me neither, which to me indicates the design's compromises are at
worst sub-optimally documented and at best as good as any reasonable
alternative. Plus, by the time someone gets into a situation where
the LSP matters, they know how the Foundation classes really work.
So, for example, they take extra care if they need to iterate through
an NSArray in a threadsafe way.
--Andy
_______________________________________________
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.