🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: aus.computers.java
Article #232

Re: Multiple interfaces

#232
From: Steve Horsley
Date: Wed, 19 Jun 2002 21:25
65 lines
2697 bytes
On Tue, 18 Jun 2002 19:40:17 +0100, "Coho (Richard Swain)"
<vibron@krang.f9.co.uk> wrote:

>Use Facets.
>
>interface Intf1{
>     public void X();
>}
>
>interface Intf2{
>     public void X();
>}
>
>class MyClass
>{
>      private void intf2X()
>      {
>         // do interface 2 X() implementation
>      }
>
>      private void intf1X()
>      {
>         // do interface 1 X() impementation
>      }
>
>     Intf1  getIntf1()
>     {
>        return new Intf1()
>        {
>           public void X()
>           {
>              intf1X();
>           }
>        };
>     }
>
>     Intf2  getIntf2()
>     {
>        return new Intf2()
>        {
>           public void X()
>           {
>              intf2X();
>           }
>        };
>     }
>}
>
>Then you can use   myclassinstance.getIntf2().X() or 
>myclassinstance.getIntf2().X() depending which you want to use/call.
>


Hmm. I see the idea, but it's not exactly polymorphic, is it. You
almost need to create a new interface:

interface ThingThatDoesIntf1AndIntf2 {
    Intf1 getIntf1();
    intf2 getIntf2();
}

Except that you can't even pass this object round to a method that
expects to be given an Intf1 or an Intf2.

Steve
Technical Details
Message-ID: <3d10edc6.1491361@news.virgin.net>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newspeer1-gui.server.ntli.net!ntli.net!news6-win.server.ntlworld.com.POSTED!not-for-mail
References: <1024283082.192985@web.apex.net.au> <JScP8.111$Fv1.17660@newsread2.prod.itd.earthlink.net> <1024289793.45649@web.apex.net.au> <pan.2002.06.17.07.46.24.235390.777@databasix.com> <3D0F7E91.5010401@krang.f9.co.uk>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10a146,113f3357bc588129
X-Google-Attributes: gid10a146,public
X-Google-Thread: f74b3,113f3357bc588129
X-Google-Attributes: gidf74b3,public
X-Google-Thread: 10d6db,113f3357bc588129
X-Google-Attributes: gid10d6db,public
X-Google-ArrivalTime: 2002-06-19 14:18:29 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newspeer1-gui.server.ntli.net!ntli.net!news6-win.server.ntlworld.com.POSTED!not-for-mail
From: steve.horsley1@virgin.net (Steve Horsley)
Newsgroups: aus.computers.java,borland.public.jbuilder.java.language,comp.lang.java.programmer
Subject: Re: Multiple interfaces
Message-ID: <3d10edc6.1491361@news.virgin.net>
References: <1024283082.192985@web.apex.net.au> <JScP8.111$Fv1.17660@newsread2.prod.itd.earthlink.net> <1024289793.45649@web.apex.net.au> <pan.2002.06.17.07.46.24.235390.777@databasix.com> <3D0F7E91.5010401@krang.f9.co.uk>
X-Newsreader: Forte Free Agent 1.21/32.243
Lines: 65
Date: Wed, 19 Jun 2002 21:25:04 GMT
NNTP-Posting-Host: 62.253.73.200
X-Complaints-To: abuse@virgin.net
X-Trace: news6-win.server.ntlworld.com 1024521505 62.253.73.200 (Wed, 19 Jun 2002 22:18:25 BST)
NNTP-Posting-Date: Wed, 19 Jun 2002 22:18:25 BST
Organization: Virgin Net Usenet Service