comp.lang.ada
 help / color / mirror / Atom feed
From: "Robert I. Eachus" <rieachus@comcast.net>
Subject: Re: Usage of Interfaces with Ada 95
Date: Sun, 28 Sep 2003 18:22:44 GMT
Date: 2003-09-28T18:22:44+00:00	[thread overview]
Message-ID: <3F7726E4.6040402@comcast.net> (raw)
In-Reply-To: 4nii41-067.ln1@boavista.snafu.de

Michael Erdmann wrote:

> The nice thing about java interfaces is that all classes
> are derived from the Object class.

Your opinion.  I like having unrelated classes unrelated.

>                                    This is not the case in Ada,
> there i dont have such a thing as the Object class. And it seems
> that i need use generics making the handling a little bit 
> complicated because:
> 
>    1. Define a generic package with your abstract interface
>       which has a type as argument...

> I am looking for a way of avoiding step 1.

The way to avoid step 1 is to use a standard package library like
Charles.

 >    2. Specialize the interface for the required type,
 >       which is still abstract.
 >    3. Implement classes around the specialzed types.

In the Ada world we often take a different view of what is going on 
here.  You want to have some object class, call it Foo, and a container 
class.  In most object oriented languages you do that by inheriting from 
both Foo and a container class, say Queue.  So you create a 
Foo_with_Queues class.

In Ada, you can do that.  Or you can Keep Foo separate from the 
Queue_of_Foo class.  That way you can put objects of type Foo in a 
Queue_of_Foo and get them back out again. If you also have Tree_of_Foo, 
you can take an item from a Tree_of_Foo and put it in a Queue_of_Foo 
without having the class Foo, as such, as a subclass of either.  (Or you 
can have a single object in several different queues.)

Yes, if you are constantly putting Foo objects into and out of queues, 
and an object is allowed to be in only one queue at a time, having the 
necessary links as part of the object state is more efficient.  If 
instead Foo objects are found in several different containers or types 
of containers, having the container implementation separate from the 
object state is a big win.

Which style is better for your application is highly dependent on the 
application.  But if the language only gives you a hammer, you implement 
everything with nails.

-- 
                                                     Robert I. Eachus

"Quality is the Buddha. Quality is scientific reality. Quality is the 
goal of Art. It remains to work these concepts into a practical, 
down-to-earth context, and for this there is nothing more practical or 
down-to-earth than what I have been talking about all along...the repair 
of an old motorcycle."  -- from Zen and the Art of Motorcycle 
Maintenance by Robert Pirsig




  parent reply	other threads:[~2003-09-28 18:22 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-26 16:36 Usage of Interfaces with Ada 95 Michael Erdmann
2003-09-26 16:50 ` chris
2003-09-26 16:55 ` Hyman Rosen
2003-09-26 19:10   ` Michael Erdmann
2003-09-26 20:37     ` Hyman Rosen
2003-09-27 15:05       ` Michael Erdmann
2003-09-28  2:11         ` Matthew Heaney
2003-09-29  2:25         ` George Shapovalov
2003-09-28  2:14   ` Matthew Heaney
2003-09-28  8:28     ` Michael Erdmann
2003-09-28 14:33       ` Matthew Heaney
2003-09-28 15:09         ` Michael Erdmann
2003-09-28 21:50           ` Matthew Heaney
2003-09-30  4:57             ` Michael Erdmann
2003-09-30 10:02               ` Mário Amado Alves
2003-09-30 12:31               ` Matthew Heaney
2003-09-30 19:58                 ` Michael Erdmann
2003-09-28 17:10         ` Simon Wright
2003-09-28 21:52           ` Matthew Heaney
2003-09-28 21:58           ` Matthew Heaney
2003-09-29 19:37             ` Georg Bauhaus
2003-09-29 19:45               ` Georg Bauhaus
2003-09-30  7:10               ` Preben Randhol
2003-09-29 20:11             ` Simon Wright
2003-09-29 22:56               ` Matthew Heaney
2003-09-30 14:53                 ` Matthew Heaney
2003-09-30 16:13                   ` Preben Randhol
2003-09-29 13:49           ` Matthew Heaney
2003-09-28 18:22       ` Robert I. Eachus [this message]
2003-09-29  3:02         ` Hyman Rosen
2003-09-30  3:11           ` Robert I. Eachus
2003-09-30 13:38             ` Hyman Rosen
2003-09-30 21:46               ` Robert I. Eachus
2003-09-30 22:10                 ` Hyman Rosen
2003-10-01  2:30                   ` Robert I. Eachus
2003-10-01  2:41                   ` Robert I. Eachus
2003-10-01 13:21                     ` Hyman Rosen
2003-10-01 17:01                       ` Robert I. Eachus
2003-10-01 18:46                       ` Matthew Heaney
2003-09-29 14:52       ` Stephen Leake
2003-09-29 23:00         ` Matthew Heaney
2003-09-30 12:49           ` Marin David Condic
2003-09-30 23:48             ` Matthew Heaney
replies disabled

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