From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,309015504ed37ff0 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-09-28 11:22:46 PST Path: news1.google.com!newsfeed.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!elnk-nf2-pas!newsfeed.earthlink.net!wn14feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi.com!sccrnsc02.POSTED!not-for-mail Message-ID: <3F7726E4.6040402@comcast.net> From: "Robert I. Eachus" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2) Gecko/20021120 Netscape/7.01 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Usage of Interfaces with Ada 95 References: <1064595326.831730@master.nyc.kbcfp.com> <4nii41-067.ln1@boavista.snafu.de> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 24.34.139.183 X-Complaints-To: abuse@comcast.net X-Trace: sccrnsc02 1064773364 24.34.139.183 (Sun, 28 Sep 2003 18:22:44 GMT) NNTP-Posting-Date: Sun, 28 Sep 2003 18:22:44 GMT Organization: Comcast Online Date: Sun, 28 Sep 2003 18:22:44 GMT Xref: news1.google.com comp.lang.ada:82 Date: 2003-09-28T18:22:44+00:00 List-Id: 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