Re: OON: "Subclassing" algorithms

From: Jan Galkowski (jan@solstice.digicomp.com)
Date: Thu Apr 24 1997 - 11:39:33 EST


On Thu, 24 Apr 1997 17:59:51 +0200 Konrad Hinsen <hinsen@ibs.ibs.fr>
wrote, in part:

[snip]

: Suppose I have an algorithm for a specific problem, and an
: implementation that works. Now I want to tackle a similar problem that
: can be solved by a similar algorithm. All it takes is perhaps the
: modification of one step, or the addition of one. I would like to be
: able to "inherit" the working implementation while just replacing or
: adding small parts of it. And of course I do not want to modify the
: existing (supposedly well tested) code.

This is the $100 question for all of object-oriented programming. IMO,
if the step to be replaced is one of the methods (reader or writer
functions) for the existing object, then all is well, you win-- One
replaces the method with the new one. If the step is somehow distributed
over several methods or maintenance code, you lose: OO isn't better
than any kind of conventional programming. Of course, there's a lot
of hand-waving about conceiving, devising, and implementing proper
objects, but IMO that's b.s.: There's no real method for this.

: One possibility would be to write each step as a function and call
: these function via pointers that can be substituted. But that would be
: a very inefficient solution; what I want is fully optimized code for
: all versions of the algorithm. So I would certainly need the source
: code of everything.

In fact, the great disatisfaction regarding your original problem
statement is one of the powerful motivators for work on
<A HREF="http://www.md.chalmers.se/~magnus/afp/overview.html">functional
programming</A>-- To be able to treat functions as first-class entities
and lose no efficiency.

: Has any work been done on this kind of problem? Or is it a stupid
: idea due to some limitations I have overlooked?

There's no such thing as an honestly asked stupid question. If one
is constrained to use existing methods, I don't think there's much
choice but to use various generic facilities, such as those in
Ada83 or Ada95, or macro processing. There was a nice paper by
Henderson and Gimson titled "Modularization of Large Programs"
which is one of my favorites on this subject. It appeared in
SOFTWARE-- PRACTISE AND EXPERIENCE in (about) 1987, I think
in Volume 7. There, one would replace the step with a macro
parameter and change the parameter with each implementation.
Or, if one wants to do the problem directly, use
<A HREF="http://www.cs.arizona.edu/icon/www/">Icon</A>,
 <A HREF="http://haskell.cs.yale.edu/">Haskell</A>,
<A HREF="http://www.amazon.com/exec/obidos/ISBN%3D0201422794/4756-4644435-279371">
Miranda</A>, or <A HREF="http://www.ericsson.se:800/cslab/erlang/">
Erlang</A> as your programming medium.

: --
: -------------------------------------------------------------------------------
: Konrad Hinsen | E-Mail: hinsen@ibs.ibs.fr
: Laboratoire de Dynamique Moleculaire | Tel.: +33-4.76.88.99.28
: Institut de Biologie Structurale | Fax: +33-4.76.88.54.94
: 41, av. des Martyrs | Deutsch/Esperanto/English/
: 38027 Grenoble Cedex 1, France | Nederlands/Francais
-------------------------------------------------------------------------------

Jan Theodore Galkowski,
 developer, statistician,
   Digicomp Research Corporation,
   Ithaca, NY 14850-5720
 jan@digicomp.com
 (also jtgalkowski@worldnet.att.net)



This archive was generated by hypermail 2b29 : Wed Feb 20 2002 - 03:20:05 EST