Article View: aus.computers.java
Article #275Re: Multiple interfaces
From: Tristan Reeves
Date: Mon, 17 Jun 2002 07:25
Date: Mon, 17 Jun 2002 07:25
45 lines
3179 bytes
3179 bytes
"Sted Alana" <Sted_Alana@hotmail.com> wrote in message
news:3d0d7f8d_1@news.iprimus.com.au...
>
> > Nothing in particular, it's a general observation related to custom
> > interfaces:
> >
> > interface Intf1{
> > public void X();
> > }
> >
> > interface Intf2{
> > public void X();
> > }
> >
> > class MyClass implements Intf1, Intf2{
> > ????
> > }
>
> By observation, it seems silly to implement two or more interfaces with
the
> same abstract methods. First because its extraneous, and second because of
> the name clashes. How is Java suppose to know which abstract methods
> requries implementation? How do other programming languages resolve this
> problem?
>
Hi Sted,
Well, you might get two such interfaces from two independant libraries. They
could *easily* have a name clash. An example I like (I can't give credit
because of my poor memory, but it was someone on one of the java newsgroups
who gave it, I think) is the example of Draw() being used in the context of
a lottery library and also in the context of a graphics library. If you use
both of these libraries in an App that graphically displays lottery draws,
you might get a name clash in a class that "draws a draw" (if you see what I
mean).
The best way for dealing with this that I have seen is in Delphi (object
pascal), in which you can have "name-resolution" statements in your class
declaration. So you can say Intf1.X()=MyClass.Interface1X(), and then calls
to that interface method [X()]will get mapped to the specified method
[Interface1X()].
Regards,
Tristan
Technical Details
Message-ID:
<1024298741.828605@web.apex.net.au>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!xmission!news-out.spamkiller.net!propagator2-maxim!propagator-maxim!news-in.spamkiller.net!snewsf0.syd.ops.aspac.uu.net!news1.optus.net.au!optus!news.mel.connect.com.au!news.can.connect.com.au!not-for-mailReferences:
<1024283082.192985@web.apex.net.au> <JScP8.111$Fv1.17660@newsread2.prod.itd.earthlink.net> <1024289793.45649@web.apex.net.au> <3d0d7f8d_1@news.iprimus.com.au>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10d6db,113f3357bc588129 X-Google-Attributes: gid10d6db,public X-Google-Thread: 10a146,113f3357bc588129 X-Google-Attributes: gid10a146,public X-Google-Thread: f74b3,113f3357bc588129 X-Google-Attributes: gidf74b3,public X-Google-ArrivalTime: 2002-06-17 00:25:57 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!xmission!news-out.spamkiller.net!propagator2-maxim!propagator-maxim!news-in.spamkiller.net!snewsf0.syd.ops.aspac.uu.net!news1.optus.net.au!optus!news.mel.connect.com.au!news.can.connect.com.au!not-for-mail From: "Tristan Reeves" <moonshine@apex.net.au> Newsgroups: aus.computers.java,borland.public.jbuilder.java.language,comp.lang.java.programmer Subject: Re: Multiple interfaces Date: Mon, 17 Jun 2002 17:25:35 +1000 Organization: APEX Internet Lines: 47 Message-ID: <1024298741.828605@web.apex.net.au> References: <1024283082.192985@web.apex.net.au> <JScP8.111$Fv1.17660@newsread2.prod.itd.earthlink.net> <1024289793.45649@web.apex.net.au> <3d0d7f8d_1@news.iprimus.com.au> NNTP-Posting-Host: news.apex.net.au X-Trace: auwa.connect.com.au 1024298749 2208 210.9.132.20 (17 Jun 2002 07:25:49 GMT) X-Complaints-To: abuse@connect.com.au NNTP-Posting-Date: 17 Jun 2002 07:25:49 GMT X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Cache-Post-Path: web.apex.net.au!unknown@203.63.14.43 X-Cache: nntpcache 2.3.3 (see http://www.nntpcache.org/)