Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Interfaces

 
Mathews P Srampikal
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what are the advantages of interface other than mutiple inheritance and Polymorphysm.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic