Anton <anton.txt@[EMAIL PROTECTED]
> writes:
>Miss Elaine Eos:
>> * Inheritance allows one to design hierarchies of "things" (objects)
>> that share common functionality and to share the code that is common
>> among them. The shared code allows bug fixes, enhancements,
>> modifications, debugging, etc., across an entire range of related
>> things.
>Well, this is a very general principle of... how to call it?.. unicity:
>same actions should be expressed by the same code. A simpler example is
>declaring a constant instead of hard-coding some number in several places
>in the code. It's kinda forcing integrity, a guarantee you won't screw
>things up by changing this value...
>I think, PP-programms should also be designed with this principle in
mind.
>Howeever, instead of object hierarchy, PP offers Unit/Procedure hierarchy
>-- a different means for the same thing. And now I am interested in which
>cases the OOP's approach to unicity exceeds that of PP. There should be
>cases when with OOP it's much easier to maintain unicity.
As I see it, OO is all about following certain design and coding
ideologies, this
"unicity" being one of them. While good programmers can do all these
things without
OO features in language, OO language encourages and enforces them.
Hopefully
this makes it easier for not-so-good programmers to make a bit better
code. OO
features make some things like dynamic binding much easier and probably
less error
prone (thinking C++ here).
>> Note that you can do OOP in PP, without any language helpfulness.
>That's interesting! Is there a way to "emulate" simple incapsulation? If
I
>define a function and a data structure, and even put a pointer to the
>former into the latter, I will still have to pass the record to my
>function. Otherwise it'll not be able to access its objects's
properties...
>The call would look rather redundant: Obj.Function(Obj,<other
parameters>);
I would say difference between FuntionToCall(MyDataObject) and
MyDataObject.FunctionToCall() is very small. Nice syntactic sugar, but
only that.
However, constructors and destructors are nice sometimes.
>Plus OOP-like data hiding -- no idea how to implement it.
Well, you can have your datastructures behind void pointers, but that's
quite a
dirty hack to enforce hiding. Ofcourse you'll also lose all typesafety.
>> * Data hiding helps one avoid the pitfalls associated with changing a
>> value directly when said value change is linked to other values.
>> Again, this can be done in PP, but is prone to error, if someone
>> forgets to change all the appropriate related info, setting a variable
>> without using its "setter."
>Well, PP has it's own Data Hiding. Units' INTERFACE and IMLEMENTATION
>sections, nested procedures and functions, restricted types, detailed
>control over ex****t (MODULA-like),... It's just different from OOP.
Not all PP-languages have these features. Someone might argue that these
are OO
features. I don't think there is a strict line between OO languages and PP
languages, nor I think there's a need for one.
--
What sorcery, what spells, have brought thee here?


|