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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fac41,953e1a6689d791f6 X-Google-Attributes: gidfac41,public X-Google-Thread: 103376,953e1a6689d791f6 X-Google-Attributes: gid103376,public X-Google-Thread: fdb77,953e1a6689d791f6 X-Google-Attributes: gidfdb77,public X-Google-Thread: f79bb,953e1a6689d791f6 X-Google-Attributes: gidf79bb,public From: fjh@murlibobo.cs.mu.OZ.AU (Fergus Henderson) Subject: Re: Eiffel and Java Date: 1996/11/02 Message-ID: <55fhfu$8p0@mulga.cs.mu.OZ.AU>#1/1 X-Deja-AN: 193950815 references: <550sm2$sn1@buggy.news.easynet.net> <55562c$nkd@mulga.cs.mu.OZ.AU> <55ffdb$cki@bagan.srce.hr> organization: Comp Sci, University of Melbourne newsgroups: comp.lang.eiffel,comp.lang.ada,comp.lang.sather,comp.lang.java.advocacy Date: 1996-11-02T00:00:00+00:00 List-Id: dbudor@zems.fer.hr (Darko BUDOR) writes: ]Fergus Henderson (fjh@mundook.cs.mu.OZ.AU) wrote: ]: Suppose I have two existing library classes (perhaps supplied by different ]: vendors) which have some commonality, but don't inherit from a common ]: base class. In Sather, one can simply create a new interface and ]: declare these classes to be instances of this interface, without ]: modifying the existing code. ]: ]: (Is that possible in Java?) ] ]Yes, it is. If your code below is the only way of doing it, then I would say that it *isn't* possible in Java. The code below doesn't do the same thing as the Sather code -- it has significant disadvantages. ]Suppose you have 2 classes from different vendors, class A and ]class B, with common methods void foo() and void bar(). You can declare an ]interface for common methods: ] ]public interface common { ] public void foo(); ] public void bar(); ]} Fine so far... ]Now declare 2 new classes: ] ]public class MyA extends A implements common { ] /* need constructors */. ]}; Disadvantage number one: you have to manually delegate all the constructors. That is tedious and causes maintenance difficulties when someone later adds new constructors for A. ]and use MyA and MyB instead of A and B. Disadvantage number two: you can't use the new interface on the original types. This is *really* bad news. It basically means is that you can't use this method when interfacing with existing code that uses A and B rather than MyA and MyB. -- Fergus Henderson | "I have always known that the pursuit WWW: | of excellence is a lethal habit" PGP: finger fjh@128.250.37.3 | -- the last words of T. S. Garp.