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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,2ff5c149712ec0eb X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!tiscali!newsfeed1.ip.tiscali.net!proxad.net!proxad.net!feeder2-2.proxad.net!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Ada Interfaces and the Liskov Substitution Principle Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <1179953657.839272.160320@a26g2000pre.googlegroups.com> <1179991769.376381.252010@m36g2000hse.googlegroups.com> <12h6mi42jcha0.7f9vfsnihjwr$.dlg@40tude.net> <1180011507.159515.46920@o5g2000hsb.googlegroups.com> <1180079541.558215.256570@h2g2000hsg.googlegroups.com> Date: Fri, 25 May 2007 10:21:24 +0200 Message-ID: NNTP-Posting-Date: 25 May 2007 10:19:17 CEST NNTP-Posting-Host: 297cbee9.newsspool1.arcor-online.net X-Trace: DXC=WhIMAJ@@C`Kgj[ZPFj7ehOic==]BZ:afN4Fo<]lROoRAFl8W>\BH3YB:NZd4@`JEeADNcfSJ;bb[EFCTGGVUmh?DLK[5LiR>kgB4^S[ On 25 May 2007 00:52:21 -0700, Maciej Sobczak wrote: > On 25 Maj, 00:58, "Randy Brukardt" wrote: > >> Given the current Ada rules, what classwide assignment is good for is >> *re*construction: >> >> procedure Do_Something(Y : out Object'Class) is >> begin >> Y := Constructor_Func (); >> end Do_Something; >> >> that is, the replacement of an object with different one of the same type. >> The Constructor_Func is dispatching on the real type of the LHS object > > Interesting. In most of the cases, the factory function creates the > object of whatever type *it* decides (based on its parameters or some > other input values) and initializes the class-wide type accordingly. Not necessarily. In one case, I generate nodes of a graph. The nodes can be of different types regarding their persistence. For example, there are nodes resident in the database and nodes resident in the memory etc. Now, when creating a new node a factory moves along two axes: the standard root/branch/leaf hierarchy and persistence stuff. For the latter the factory receives an already existing node, to create "a new node like this." This is not copying. Ideally it should double dispatching along both axes. I have implemented it as: New_Node := Create (Get_Factory (Some_Existing_Node), ...); > There is a very simple rule of thumb for checking whether any given OO > pattern makes sense - try to stick it to the classical geometry > example. > If it falls off, beware. :-) You certainly mean the circle-ellipse LSP controversy... (:-)) -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de