comp.lang.ada
 help / color / mirror / Atom feed
From: "Marin David Condic" <dont.bother.mcondic.auntie.spam@[acm.org>
Subject: Re: OOD in Ada?
Date: Fri, 21 Jun 2002 13:22:47 -0400
Date: 2002-06-21T17:22:47+00:00	[thread overview]
Message-ID: <aevnd7$mkd$1@nh.pace.co.uk> (raw)
In-Reply-To: 3d135676$0$8511$cc9e4d1f@news.dial.pipex.com

"David Crocker" <dcrocker@eschertech.com> wrote in message
news:3d135676$0$8511$cc9e4d1f@news.dial.pipex.com...
> I know that Ada95 tries to support O-O development, but from my
perspective
> as an OO developer but Ada novice, it appears to me that any attempt to
> implement a large OO design in Ada will run into the following problems:
>
> 1. The infamous "withing" problem (i.e. it is not possible to declare 2
> classes A and B, each in its own package, such that A has a method taking
a
> paremeter of type "access B", and B has a method with a parameter of type
> "access A"); and
>
I'm not sure that this is somehow or other essential to OO Programming.
Perhaps you just need to consider another way of doing it rather than try to
force an idiom from another language onto Ada. If you really need to do
that, you could probably do some version of deriving A and B from some lower
level type(s) that declares an access type to the underlying type(s)'Class -
then A and B can with the base types and get the access types they need.

A solution does exist - I just don't think I'm convinced that you really
need to do that and that failure to find a way means you can't do large OO
designs in Ada.

If you absolutely insist it is essential, try this:

package Base_Class is
    type Base_Type is tagged private ;
    type Base_Ptr is access all Base_Type'Class ;
    -- etc...
private
    type Base_Type is tagged null record ;
end Base_Class ;

package Base_Class.A is
    type A is new Base_Type with private ;
private
    type A is new Base_Type with record
        B_Ptr : Base_Ptr := null ;           -- Can point to any B without
"with"
    end record ;
end Base_Class.A ;

package Base_Class.B is
    type B is new Base_Type with private ;
private
    type B is new Base_Type with record
        A_Ptr : Base_Ptr := null ;
    end record;
end Base_Class.B ;


Iyou're familiar enough with Ada and OOP, you should be able to figure it
out from here... (And no, they don't both need to derive from the same base
type and they don't need to be child packages of the base class.)




> 2. The lack of a "dot" notation (or anything similar) for calling a member
> method, making the code hard to read and hard to determine where dynamic
> binding may be taking place.
>
This is just a syntax thing - one debated here a number of times in the
past. I don't find it essential or hard to read or anything like that. But
then, I'm used to looking at it from "Method (Object)" perspective rather
than "Object->Method" form. Whatever you are used to is going to make the
other way seem "Bad". If you decide to simply Get Over It and work with the
syntax that exists, you'll find it is no more confusing or difficult than
what you are used to.

It certainly won't stop you from implementing any large OO designs and if
you take the language as a whole, I think you'll find you gain lots of
benefits from using it that outweigh whatever downsides there may be to
having to learn & use something that is "Different". (Think of the benefits
you get from things like tasks, protected types, generics, etc. Isn't that
worth a little change in the syntax you are used to?)

MDC
--
Marin David Condic
Senior Software Engineer
Pace Micro Technology Americas    www.pacemicro.com
Enabling the digital revolution
e-Mail:    marin.condic@pacemicro.com






  parent reply	other threads:[~2002-06-21 17:22 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-06-21 16:39 OOD in Ada? David Crocker
2002-06-21 17:20 ` Pat Rogers
2002-06-21 19:37   ` Ed Falis
2002-06-23  3:05   ` Ted Dennison
2002-06-23  7:03     ` tmoran
2002-06-24 21:41       ` Ted Dennison
2002-06-24 14:19     ` Stephen Leake
2002-06-21 17:22 ` Marin David Condic [this message]
2002-06-22  4:42 ` Jeffrey Carter
2002-06-22  9:18 ` Dr. Michael Paus
2002-06-22  9:47   ` Pascal Obry
2002-06-22 13:11     ` Dr. Michael Paus
2002-06-22 13:46       ` OOD in Ada? Correction Dr. Michael Paus
2002-06-22 18:21         ` Simon Wright
2002-06-28 23:57         ` Randy Brukardt
2002-07-09  8:45           ` Preben Randhol
2002-07-09 17:12             ` Mark Biggar
2002-07-09 19:40             ` Randy Brukardt
2002-06-23  3:33   ` OOD in Ada? steve_H
2002-06-23  4:55     ` Jim Rogers
2002-06-23  5:33       ` achrist
2002-06-25 18:00       ` Georg Bauhaus
2002-06-25 18:55         ` Marin David Condic
2002-07-07 18:19           ` Daniel Dudley
2002-06-23  7:46     ` Dr. Michael Paus
2002-06-24  5:06       ` steve_H
2002-06-23 19:26   ` Chad R. Meiners
2002-06-22 22:47 ` Dmitry A.Kazakov
2002-06-24 20:03 ` Kevin Cline
2002-06-25 13:32   ` David Crocker
2002-06-25 13:58     ` Marin David Condic
2002-06-26 18:16       ` tmoran
2002-06-26 18:47         ` Marin David Condic
2002-06-27 18:23           ` tmoran
2002-06-28 13:09             ` Marin David Condic
2002-06-26  0:59     ` Hyman Rosen
2002-06-26  4:57       ` Jim Rogers
2002-06-26 12:49       ` Marin David Condic
2002-06-26  9:01     ` Fraser Wilson
2002-06-29  0:08       ` Randy Brukardt
2002-07-01 11:50         ` Fraser Wilson
2002-07-05 20:02     ` Stephen J. Bevan
2002-07-09 19:19 ` Craig Carey
replies disabled

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