Re: Mutability
Re: Mutability
- Subject: Re: Mutability
- From: Ondra Cada <email@hidden>
- Date: Wed, 21 Nov 2001 17:45:52 +0100
Julien,
>
>>>>> Julien Dufour (JD) wrote at Wed, 21 Nov 2001 16:37:43 +0100:
JD> >So far as I understand OOP, the proper OO point of view is "give _any_
JD> >object to me; I'll determine what kind it is, and I'll behave
JD> >accordingly".
JD>
JD> That's not OOP, that untyped langage programming.
Yeah, untyped -- that what's an object is! There are no "types" in the
object world: anything's an object, and differences are resolved by
polymorphism, not by typing.
JD> Typechecking is compilation stage where the compiler tells
JD> you if you are doing something wrong. Stronger typesystems lead to
JD> robuster programs
____Quite the contrary!!!____
There is *always* a possibility to send an object of a different type than
compiler thought -- be it due to bad header used, or an out-of-date plugin
loaded, or an upgraded dynbamic library, or whatever.
In "your" world, the result might be just anything: crash, improper
behaviour, anything's possible. That's exactly why C++ verges on the edge of
unusability: both the compiler and programmer "know" beforehand what type the
argument has, and make the code accordingly. In reality they just _though_
they knew, something other really happens, and the result? All hell breaks
loose.
OTOH, in _object oriented_, ie. _runtime_, ie. _untyped_ world its all
right: both the compiler and programmer presumed that _any_ object can be the
argument. Therefore, the code is made so that it either works properly, or,
at the worst, it crashes properly (ie. at the place and time where the
problem occurred, and with an appropriate report).
Do believe me. The preceding two paragraphs are not some theory I have
conjured last evening; it's a very practical result of many hundreds of
thousands lines written in plain C and ObjC, of many tens of thousands lines
written in C++, and the experience with robustness, debugging, maintaining
and upgrading them.
---
Ondra Cada
OCSoftware: email@hidden
http://www.ocs.cz
2K Development: email@hidden
http://www.2kdevelopment.cz
private email@hidden
http://www.ocs.cz/oc