This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Interface" Watch "Interface" New topic


Albina Amalraj

Joined: Dec 19, 2007
Posts: 3
Any class that implements a Interface should implement all the methods defined in interface..My question is
How far it is feasible in Real time programming implementing all methods?
Is it not a extra burden to specify all the methods in class???
marc weber

Joined: Aug 31, 2004
Posts: 11343

Originally posted by Albina Amalraj:
...Is it not a extra burden to specify all the methods in class??? ...

Well, this "burden" should be weighed against the advantages of interfaces and the long-term benefits they can provide in terms of flexibility and maintenance.

Also note that abstract classes can provide partial implementation of an interface to make concrete implementation easier. For example, AbstractCollection "provides a skeletal implementation of the Collection interface, to minimize the effort required to implement this interface." In turn, AbstractList extends AbstractCollection and provides skeletal implementation of the List interface. So when ArrayList extends AbstractList, it inherits much of the implementation required to satisfy the Collection and List interfaces.

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
Albina Amalraj

Joined: Dec 19, 2007
Posts: 3
Thanks for the explaination..

Petrus Pelser
Ranch Hand

Joined: Feb 20, 2006
Posts: 132
If you find yourself implementing just one method in an interface that specifies several then you should think of creating an adapter for the interface. A lot of empty implemented methods makes your code ugly and difficult to read.
Have you checked out Aspose?
subject: Interface
It's not a secret anymore!