From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: * X-Spam-Status: No, score=1.6 required=3.0 tests=BAYES_20,REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.5-pre1 Path: eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: "G.B." Newsgroups: comp.lang.ada Subject: Re: Simple example on interfaces Date: Tue, 26 Jan 2021 08:33:53 +0100 Organization: A noiseless patient Spider Message-ID: References: <9e1b5d67-be08-4f53-aadc-fbed761a8c24n@googlegroups.com> Reply-To: nonlegitur@notmyhomepage.de Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Tue, 26 Jan 2021 07:33:53 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="2764147e1a02374b9ee02a0f237783d6"; logging-data="17255"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Ec0p2WDvjg0eh1UzS6bzPqrm0jJkt4r8=" User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 Cancel-Lock: sha1:ZY9lOAdsURIzkHKXkHDXeTyBVW8= In-Reply-To: Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:61201 List-Id: On 25.01.21 23:06, Dmitry A. Kazakov wrote: >> That is forbidden as far as the final application is concerned. The example I posted here is a simplification of a more complex scenario. > > There exist various dirty tricks to emulate full multiple inheritance but no universal solution. If you really need full multiple inheritance, choose the most important path of implementations and make types along it proper types. Other paths if simple, could tricked using > > - Min-in inheritance > - Generic packages to automate implementation of interfaces > - Memory pools to inject implementation > > Nothing of these is good. They basically work only if the depths of the secondary inheritance paths is 1. > (Mix-in inheritance?) Composition can be a good alternative, too. It can help making the type graph modular. It naturally adds separation of concerns. Is there good reason to prefer Is-A over Has-A? If all the types are related through inheritance, will refactoring become easier or harder?