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: Tue, 25 Jun 2002 09:58:23 -0400
Date: 2002-06-25T13:58:25+00:00	[thread overview]
Message-ID: <af9su1$ota$1@nh.pace.co.uk> (raw)
In-Reply-To: 3d1870b0$0$8507$cc9e4d1f@news.dial.pipex.com

That's a fair example. Is there no way you could think of it in terms of an
abstract base class - or two abstract base classes? (Base_Expression and
Base_Statement defining operations & pointers - then the actual Expression
and Statement packages descend from these & you "with" the
Base_Expression/Base_Statement as needed?)

About the only thing you'd actually need in the *spec* would be a pointer to
the (base) types. The bodies would need to know about the operations and
here it doesn't present any problem with the "with" statement.

Another thing I have done when I want a whole slew of classes that might
need to be mixed & matched is to build my class heierarchy all deriving from
a single base class that defines an access type & maybe some primitive
operations for serialization, etc. (This is similar to the structure of the
MFC - everything deriving from a base class.) Note that this pretty much
circumvents any type safety you might have had on the pointers since they
can now point to *anything* in the tree (but not stuff external to the tree,
so you get at least *some* safety.) However, it does let you work with
heterogeneous collections of stuff. (I've been tinkering with some OOD stuff
relating to the XML DOM and this is pretty much how I did it.)

MDC

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


"David Crocker" <dcrocker@eschertech.com> wrote in message
news:3d1870b0$0$8507$cc9e4d1f@news.dial.pipex.com...
> Let me give you and others who have replied to my posting a real example
of
> an OO system where the "withing" problem occurs and I can't see an easy
way
> out of it.
>
> A compiler is being written. The compiler has to know about objects of
class
> Expression and Statement. Each of these is actually an abstract class with
> many descendents (because there are many types of expression etc.).
>
> Many types of statement contain expressions (e.g. assignment statements),
> therefore these Statement subclasses need to know about Expression.
>
> Many of the expression classes also need to know about statements. For
> example, an Expression has a method to generate statements to evaluate it
at
> run-time. The language I am compiling also allows a few types of statement
> to be embedded within an expression.
>
> What I am left with is:
>
> Class Expression need to declare an abstract method that returns a
Statement
> (or another class that encapsulates a Statement). Many descendents of
> Expression refer to particular descendents of Statement (e.g.
> ConditionalExpression will refer to ConditionalStatement).
>
> Many descendents of Statement contain variables of type Expression (or
> Expression'class in Ada).
>
> There is no way I want to put all the expression and statement classes in
> one package! The natural way to construct the project is to put each class
> in its own file (and hence package, if I am using Ada).
>
> Things get even worse when I introduce TypeExpression.
>
> Yes, there are lots of cross-references between classes in this
application,
> but these arise naturally from the nature of the problem.
>
> --
> David Crocker
> Escher Technologies Ltd.
> www.eschertech.com
>
>
> "Kevin Cline" <kcline17@hotmail.com> wrote in message
> news:ba162549.0206241203.1d375611@posting.google.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");
> >
> > It's possible to do this in C++ but it's seldom a good idea.  Instead
> > one should declare all mutually dependent classes in a single header
> > file, and implement them in a single source file.
> >
> > The Java requirement of a separate file for each class forces one
> > to physically separate classes that aren't really separable.
> >
> > Excessive inter-class dependencies make many large OO programs
> > almost unmaintainable.
> >
> > >
>
>
>





  reply	other threads:[~2002-06-25 13:58 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
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 [this message]
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