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: 103376,104df2b9b7a2f689 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Vinzent 'Gadget' Hoefler Newsgroups: comp.lang.ada Subject: Re: Interfaces Date: Tue, 17 May 2005 13:34:12 +0000 Message-ID: <1632446.44CstxF7BU@jellix.jlfencey.com> References: <8764xj9wzf.fsf@deneb.enyo.de> <877jhz0y52.fsf@deneb.enyo.de> <1787554.lkqyR2uNLM@jellix.jlfencey.com> <874qd2cedk.fsf@deneb.enyo.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: individual.net /+Fji0SJM/lw6A3tHxRSVQlSudPbQKFdZshH6Mzn0+oy3DMF8p X-Phone: +41 62 961 13 52 X-Mood: If you knew, I had to kill you. Xref: g2news1.google.com comp.lang.ada:11066 Date: 2005-05-17T13:34:12+00:00 List-Id: Florian Weimer wrote: > * Vinzent Hoefler: > >> Florian Weimer wrote: >> >>> I wasn't sure, after reading the Java language specification, if >>> Java interfaces had the same problem. 8-> >> >> They do. > > And this behavior doesn't cause problems in practice? Of course, this > would be a rather strong indicator that no additional complexity is > necessary. 8-) Well, the idea behind this is: If you implement two interfaces which share methods with the same name (and signature), you most likely wanted to implement only one of these methods anyway, so there actually is only one, no matter how many interfaces share this method. I'm not sure if I agree with that particular view point "there can be only one", but that's what an 10-year Java-Professional was paid to tell us ;-> and it seems like a clever trick to avoid the problems you would get otherwise. Ok, some code to make the point more clear: interface Int_A { void Foo(); void Bar(); } interface Int_B { void Foo(); void Baz(); } class One implements Int_A, Int_B { void Foo() { ... }; // required from either Int_A or Int_B void Bar() { ... }; // required from Int_A void Baz() { ... }; // required from Int_B } Ok, so far so good. Now the "tricky" part: class Two implements Int_A { void Foo() { ... }; // Int_A void Bar() { ... }; // Int_B } class Three extends Two implements Int_B { void Foo(); // surprise! already implemented by "A.Foo()"! // so this is an override of "Two.Foo()" void Baz(); // required from Int_B } So in this case "class Three" actually only needs to implement "Baz()" from "Int_B", because "Foo()" was already implemented by "Int_A". I don't know if Ada interfaces are supposed to have the same behaviour, but if they do, this doesn't seem much of a problem, since the Java community seems to be quite satisfied with the solution. Or perhaps they just don't know better. :-> Vinzent. -- worst case: The wrong assumption there actually is one.