🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: aus.computers.java
3 messages
3 total messages Started by Alan Fri, 14 Apr 2000 00:00
Interfaces Why?
#881
Author: Alan
Date: Fri, 14 Apr 2000 00:00
13 lines
893 bytes
Hi

Can some one tell me why & when you would use an interface?

I know how to write one and how to upcast from the concrete class
to the interface, I just can't see why you want to do this.

is to protect the other methods?
are they more "light weight"?

Thanks

Alan
Re: Interfaces Why?
#882
Author: Ross Vumbaca
Date: Fri, 14 Apr 2000 00:00
28 lines
1395 bytes
Hi,

Alan wrote:
 
> Can some one tell me why & when you would use an interface?

If you want multiple (perhaps different approach/performing)
implementations to one standardardised interface.. Hmm I dunno what..
You raised a good question (for me anyway)

Regards,

Ross..
 
-- 
*TO E-MAIL ME: Reverse the order of the domain name in my e-mail
address.*

Ross Vumbaca, a 'poor' Uni student at USyd.edu.au
http://www.fl.net.au/~rossv, e-mail: rossv@fl dot net dot au (fix this
if you e-mail me!)

Running on an Amiga 3000, NEC M700 17" thingy,
030/25, ECS, 8Mb Fast, 2Mb Chip, SCSI HDD's (never mind their size)
Kickstart 3.1 (40.68), OS 3.5, Linux 2.0 (RedHat 5.1) and an Opalvision
card -
("Designed in Australia", and keeping the Zorro bus populated).
--
Re: Interfaces Why?
#886
Author: Paul Murray
Date: Fri, 14 Apr 2000 00:00
44 lines
2157 bytes
> Hi
>
> Can some one tell me why & when you would use an interface?
>
> I know how to write one and how to upcast from the concrete class
> to the interface, I just can't see why you want to do this.
>
> is to protect the other methods?
> are they more "light weight"?

I don't know what upcasting might be. Upsizing and upgrading, yes, but not
upcasting.

Interfaces can permit multiple inheritance, but the main use is in alowing
class hierarchies to specify, uuuh, "plug compatibility". It allows classes
to agree on a set of methods to communicate with one another with.

If class A extends class B, then the meaning is "a B is an A, with extras".
If class A implements I1, I2 and I3, the meaning is "A class A can do I1
stuff, I2 stuff and I3 stuff".

If Class C needs to hold a reference to a class that can do I2 stuff, it can

class C {
    I2 i2 = null;

    void setI2FaciltyProvider(I2 i2) { this.i2=i2;}
}

Without having to care what kind of class is ultimately doing the things
that an i2 does.

extending classes, OTOH, allows you to biorrow *functionality* from a base
class without rewriting it all.

Repeat after me "intefaces are *specification*, classes are
*implementation*"


Saaay - does anyone know whay they didnt put static methods in interfaces?
You can have static variables.
--------------------------------------------------------------
http://www.users.bigpond.com/pmurray
ICQ: 26066755
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads