Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Java in General and the fly likes Interfaces Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Interfaces" Watch "Interfaces" New topic
Author

Interfaces

Mathews P Srampikal
Ranch Hand

Joined: Nov 26, 2002
Posts: 211
what are the advantages of interface other than mutiple inheritance and Polymorphysm.


Thanks,
Mathews
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
You can use interfaces to influence package dependencies. Say I want to write a new Swing listener. I must implement an interface defined by Swing. So I depend on Swing, even though Swing is calling me. It would be very bad if Swing depended on me and had to release an update to Swing for every new listener I wrote!
The Dependency Inversion Principle of OO design is all about this. That link is to something I wrote, which in turn has a link to Rober Martin's golden font of wisdom.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
 
wood burning stoves
 
subject: Interfaces
 
Similar Threads
How To Call Two Different Classes From the Main Program Using the Same API?
interface extends interface ?
Home interface or Home Interface stub
Time Capsule
Writing an Interface