comp.lang.ada
 help / color / mirror / Atom feed
From: Jean-Pierre Rosen <rosen@adalog.fr>
Subject: Re: prefix notation
Date: Mon, 12 Mar 2007 13:27:57 +0100
Date: 2007-03-12T13:27:57+01:00	[thread overview]
Message-ID: <i0h3te.mum.ln@hunter.axlog.fr> (raw)
In-Reply-To: <mailman.117.1173700418.18371.comp.lang.ada@ada-france.org>

Ali Bendriss a �crit :
> To be able to use the prefix notation I understand that each operation on an 
> object must be in the same package of the object himself.
Like in other OO languages, where you can apply the prefix notation only 
to member functions.

> What about if I have a big number of operation and I would like the user to 
> write something like 
> 
> procedure test is
>  Img : Image_Obj;
> begin
>     Img.Read ("test.tiff"); Img.Rotate(90); Img.Draw(Circle);....;
>     Img.SetPixel ((100,72), Red)); 
>     Img.Write ("test.gif");
> end test;
> 
> Is there some way to split the package to still have something readable 
> (notably the specification) ?
> What other facility may I use for that purpose.
>  
I would suggest to make a clear distinction between "methods" and 
"operations". A method is something where it makes sense for each object 
to implement it in a different way: for example, a square will not 
implement "draw" the same way as a circle will.

An operation is a subprogram that operates on an object, but where the 
implementation is the same for every kind of object. "Move" is always 
equivalent to Erase-Set_X_Y-Draw. This is not a method, since it should 
not depend on which kind of objects it operates on.

I don't know exactly what you are trying to achieve, but is Read a 
property of Img? To me, it looks like a property of a Tiff object. The 
method depends on the format of the file, not on the object being read. 
Similarly, isn't Draw a method of Circle rather than Img? etc.

There is no general rule, but often if you end up with too many methods, 
it may well be that they don't belong to the right object.

(BTW: the whole Java library is full of these badly assigned methods!)

My 5cts...
-- 
---------------------------------------------------------
            J-P. Rosen (rosen@adalog.fr)
Visit Adalog's web site at http://www.adalog.fr



  reply	other threads:[~2007-03-12 12:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-12 11:53 prefix notation Ali Bendriss
2007-03-12 12:27 ` Jean-Pierre Rosen [this message]
2007-03-12 19:02   ` Ali Bendriss
2007-03-12 20:20     ` Adam Beneschan
2007-03-12 22:00       ` Ali Bendriss
2007-03-12 20:50     ` Adam Beneschan
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox