🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.api
Article #2028

Re: When to use interfaces in OOP

#2028
From: Dick Gerrits
Date: Wed, 27 Jun 2001 13:37
52 lines
2843 bytes
Joi Ellis,

Thank you for your explanation.
As I understand from your explanation the power/strength of interfaces is
that you can
pass objects of different classes that implements the SAME interface to
another object
which has declared its methods to be of  type <interface>.

Btw, can you offer me an example which implements interfaces as your
explained.
Thank you in advance.

Witte van Moort B.V.
Dick Gerrits
dgerrits@wvm.nl

-0-0-

"Joi Ellis [TeamB]" <joi@aravox.com> schreef in bericht
news:3b39d697$1_1@dnews...
> Dick Gerrits <dgerrits@wvm.nl> wrote:
>
> I like interfaces because they allow you to name a generic type of object
> as a parameter without demanding that the classes of the actual objects
> being passed extend from some common ancestor.
>
> For instance, I have an interface called MushConnector which specifies a
> certain set of methods which must be implemented.  I have a parent class,
> MushConnection, which implements all of the methods in a generic way.
> I then subclass that with into TinyMushConnection which replaces some of
> the generic methods with methods containing remote command syntax unique
> to TinyMush.
>
> If I then decide to implement a MushConnector for a game which has no
> resemblance to Mush at all, say StarshipTraders, then I can create a brand
> new parent class, implement MushConnector in it, and still pass objects of
> that class into my display gui.  The Gui declares its methods to be of
> type MushConnector, not MushConnection.  This is much more flexible than
if
> I demanded everything extend MushConnection itself.
>
> One of the interfaces I use the most is Runnable.  This lets  you turn any
> class into its own thread, without having to extend the Thread class
itself.
>
>
> --
> Joi Ellis (TeamB)               http://www.teamb.com/
> No direct email, please.
> For best results, post on news server newsgroups.borland.com!
> Newsgroup Info: http://www.borland.com/newsgroups/guide.html
Technical Details
Message-ID: <3b39ea6d_1@dnews>
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews
References: <3b39c705_1@dnews> <3b39d697$1_1@dnews>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1089d0,a43ea4662650fd72
X-Google-Attributes: gid1089d0,public
X-Google-ArrivalTime: 2001-06-27 07:26:49 PST
From: "Dick Gerrits" <dgerrits@wvm.nl>
Newsgroups: borland.public.jbuilder.java.api
References: <3b39c705_1@dnews> <3b39d697$1_1@dnews>
Subject: Re: When to use interfaces in OOP
Date: Wed, 27 Jun 2001 15:37:27 +0200
Lines: 54
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4133.2400
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
NNTP-Posting-Host: 213.116.112.245
Message-ID: <3b39ea6d_1@dnews>
X-Trace: dnews 993651309 213.116.112.245 (27 Jun 2001 07:15:09 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews