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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,a270a1fc28d4f812 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-06-25 06:31:30 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.tele.dk!small.news.tele.dk!193.174.75.178!news-fra1.dfn.de!news-lei1.dfn.de!newsfeed.freenet.de!bnewspeer01.bru.ops.eu.uu.net!bnewsifeed03.bru.ops.eu.uu.net!bnewsifeed02.bru.ops.eu.uu.net!lnewspost00.lnd.ops.eu.uu.net!emea.uu.net!not-for-mail From: "David Crocker" Newsgroups: comp.lang.ada References: <3d135676$0$8511$cc9e4d1f@news.dial.pipex.com> Subject: Re: OOD in Ada? Date: Tue, 25 Jun 2002 14:32:26 +0100 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Message-ID: <3d1870b0$0$8507$cc9e4d1f@news.dial.pipex.com> NNTP-Posting-Host: userig117.dsl.pipex.com X-Trace: 1025011888 news.dial.pipex.com 8507 195.217.54.117 X-Complaints-To: abuse@uk.uu.net Xref: archiver1.google.com comp.lang.ada:26696 Date: 2002-06-25T14:32:26+01:00 List-Id: 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" wrote in message news:ba162549.0206241203.1d375611@posting.google.com... > "David Crocker" 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. > > >