[comp.lang.pascal] Object Oriented Design

kim@kim.misemi (Kim Letkeman) (07/17/89)

 > >So the examples above would appear as something like:
 > >    >   a =: b + c;
 > >		cadd(a, b,c);
 > >
 > >    >   a := (b+c)/(d+e);
 > >		cadd(c1, b,c);
 > >		cadd(c2, d,e);
 > >		cdiv(a, c1,c2);
 > >Ugly!!!!
 > This is one approach, another which works and is not quite so ugly is

On the contrary, the following technique is uglier by virtue of being
even more obscure and messy. At least it is fairly obvious what is
being attempted in the above example. But six dereferenced pointers in
three lines of code ...

 > to create a memory pool for temporary calculation and use pointers
 > into that pool.  This way you can write
 >     TempPtr := cdiv( cadd(^b, ^c), cadd(^d, ^e) );
 >     a.x     := TempPtr^.x;
 >     a.y     := TempPtr^.y;
 > 
 > Don't flame the syntax, I haven't done this for a month at least.
 > The point is that you can use pointers to the variable rather
 > than passing a bunch of values and then you must be certain to 
 > reassign the values in the TempPtr into the original variable.
 > 
 > The pool is treated as a circular buffer which has an arbitrary
 > size (read big enough to fit your longest expression) I use a buffer
 > of 150 double precision complex numbers. 
 > 
 > If you are interested in a copy of the Turbo-Pascal source that
 > I have, send e-mail to me. I feel that it is too long to post on the
 > net.
 > 
 > Bill Murphy
 > murphy@newton.physics.purdue.edu
 > 

I am getting the feeling that TP5.5 has got a few people conviced that
they are purchasing an object oriented language. But from the comments
of those that already own it, you can't overload operators.

From an article by Bjarne Stroustrup (that appeared in IEEE Software):

"There is an important distinction here: A language SUPPORTS a
programming style if it provides facilities that make it convenient
(reasonably easy, safe and efficient) to use that style. A language
does not support a technique if it takes exceptional effort or skill
to write such programs; in that case, the language merely ENABLES
programmers to use the technique. For example, you can write
structured programs in Fortran and type-secure programs in C, and you
can use data abstractions in Modula-2, but it is unnecessarily hard to
do so because those languages do not SUPPORT those techniques."

None of the examples of object oriented design (ood) that have been
posted using TP5.5 to date have been examples of "exceptional skill".
The maintenance of programs written with these techniques will
definitely require "exceptional effort" however. All have been rather
ugly and messy. This is the antithesis of object oriented design (or
at least C++), which was created to fully support paradigms such as
data hiding and abstraction. Good support for these techniques results
in very clean and understandable code.

The twisted PASCAL code that is being displayed as an attempt at ood
does not bode well for TP's ability to support the concepts. Perhaps
those that really want to explore ood should get a good C++ compiler.

Kim Letkeman         ...uunet!mitel!spock!kim



-- 

Kim Letkeman         ...uunet!mitel!spock!kim