Prism Rationale, Part 2

Laurent Martelli martelli@iie.cnam.fr
05 Jan 1999 09:23:21 +0100


>>>>> "David" == David Jeske <jeske@home.chat.net> writes:

    >> I call this philosophy "Paradigm-Independent Software
    >> Engineering" (PISE).  The idea is that no one programming
    >> technique, be it object-oriented programming, functional
    >> programming, or even spaghetti programming :), is the right
    >> tool for every job.  But they're all the right tool for some
    >> jobs (yes, even spaghetti programming... um, maybe).

    David> I think there is definetly a related issue, where within a
    David> given language, there are different (traditionally
    David> syntactic) paradigms going on. For example, in C, do you
    David> call a function or access an array? In higher-level
    David> languages like smalltalk/self they homogonized all actions
    David> into 'method calls/message sends'. However, then the
    David> different paradigms are different protocols/collections of
    David> methods. For example, do you use an array index type access
    David> pattern (i.e. a->itemAt(1);) or do you use a linked-list
    David> access pattern?

    David> It's often the case that you have a body of code which uses
    David> one access pattern, but you'd like to store the data in
    David> another (usually superior) access pattern because you want
    David> to add some functionality.

I call this the problem of the right abstraction. I indexation is
explicitly used when it is not needed, you are using the wrong
abstraction. And you will not be able to operate on a non-indexed
collection without rewriting the code. So at every moment, you should
the right abstraction, which has the right amount of semantics. If you
have too few semantics, your function will be too complicated and will
contain code that would likely be reused somewhere else. But if you
have too many semantics, you add unnecessary constraints. 

Too many semantics is the problem of a language like C. Say you want
to draw a box, and you have already a function to draw lines. Your
probably going to write :

void DrawBox(Point points[])
{
  for(int i=0;i<4;i++)
    DrawLine(points[i mod 4], points[(i+1) mod 4]);
}

And parallelisation cannot be done automatically because the for block
implies an order which is not needed.

Laurent