Re: Mutability
Re: Mutability
- Subject: Re: Mutability
- From: Julien Dufour <email@hidden>
- Date: Wed, 21 Nov 2001 16:37:43 +0100
On Wednesday, November 21, 2001, at 02:57 PM, Ondra Cada wrote:
So far as I understand OOP, the proper OO point of view is "give _any_
object to me; I'll determine what kind it is, and I'll behave
accordingly".
That's not OOP, that untyped langage programming.
[Delete]
DMC> Really, using things like "isKindOfClass" is often a symptom of bad
DMC> design.
Is it?!? I'd say it is a symptom of _THE PROPER_, ie. run-time design,
as
compared with the bad, C++-like compile-time one!
No it's really not. You are recommending untyped langage instead of
typed ones. Typechecking is compilation stage where the compiler tells
you if you are doing something wrong. Stronger typesystems lead to
robuster programs. With the ""give _any_ object to me; I'll determine
what kind it is, and I'll behave accordingly" philosophy (untyped
philosophy), anything can happend at runtime. You then have to produce
much more complex code to check what happend and to handle invalid
cases... etc. You do compiler's work here (aren't computer there to work
instead of us).
This work SHOULD be done by the compiler. It won't commit mistake (but
you will), it is automatic, you save time and work, and you procuce more
safe code, you have less to debug! Moreover, your code will be much
faster as lot of tests are not needed anymore, and many optimisations
are made possible.
The dictinction between mutable objects and not mutable ones, even if
the same objects are used behind (I think it is the case, but we do not
have to know, that's implementation, not interface!), is a really good
thing. It uses as much as possible the poor capabilities of
ObjectiveC/Java type systems.
--
Julien Dufour