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-Thread: a07f3367d7,e276c1ed16429c03 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,UTF8 Path: g2news1.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!newsfeed.straub-nv.de!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: "J-P. Rosen" Newsgroups: comp.lang.ada Subject: Re: Ada is getting more popular! Date: Sun, 31 Oct 2010 11:38:02 +0100 Organization: Adalog Message-ID: References: <14fkqzngmbae6.zhgzct559yc.dlg@40tude.net> <8732ea65-1c69-4160-9792-698c5a2e8615@g13g2000yqj.googlegroups.com> <4cc60705$0$23764$14726298@news.sunsite.dk> <4cc6753c$0$23756$14726298@news.sunsite.dk> <4cc71e08$0$23758$14726298@news.sunsite.dk> <4cc87d7a$0$23755$14726298@news.sunsite.dk> <4cc912e1$0$23761$14726298@news.sunsite.dk> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Sun, 31 Oct 2010 10:38:09 +0000 (UTC) Injection-Info: mx01.eternal-september.org; posting-host="O1RkH+WVNUV47UyqsXe2BA"; logging-data="21293"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18fuOkIn9byo0ZTE7YuB3yx" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.9.2.12) Gecko/20101027 Thunderbird/3.1.6 In-Reply-To: Cancel-Lock: sha1:/PlXFqin/+QbUZ/bFqNFYvKzESM= Xref: g2news1.google.com comp.lang.ada:15023 Date: 2010-10-31T11:38:02+01:00 List-Id: Le 31/10/2010 06:02, Yannick Duchêne (Hibou57) a écrit : [...] > So, shall we define two root types, one with Size and Coordinate, and > another with Move ? > In my view, it is very important to make the distinction between (class-wide) subprograms and methods. A method is bound to a specific type. You don't draw a square the same way that you draw a circle, each object has its own /method/ of implementing the abstract notion. OTOH, the algorithm for moving a square is the same as for moving a circle: it is not a method, but a subprogram that operates on all graphical objects => perfectly implemented in Ada with a procedure operating on a class-wide type. Note that a class-wide subprogram is unique, cannot be redefined, and you are guaranteed that no descendant of graphical objects can change it to behave differently. FWIW, here are my criteria for using inheritance: 1) you have several types, that are too different to be modelled as variations of a single type (use discriminated types otherwise); 2) however, these types have some common logical properties, with different implementations 3) you have to maintain an heterogenous container of these various types 4) you want to call the common operations on all objects in the container Yes, graphical objects meet these criteria. You maintain a list of objects on the screen, and you want to Paint them all by iterating over the list. -- --------------------------------------------------------- J-P. Rosen (rosen@adalog.fr) Adalog a déménagé / Adalog has moved: 2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00