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.
one of the firsts that force me to choose between them is whether I want to keep body of any of the methods or not as method definitions are not allowed in interfaces. while you can give definition to one or all methods in an abstract class and still achieve the same purpose as of interface.
Also, an interface would normally be preferred where you want un-related classes (e.g. classes in different packages from different inheritance hierarchies) to be able to share some kind of functionality. Plus, interfaces are more flexible, since a class can implement multiple interfaces, whereas only one abstract class can be extended by the subclass. If you can see that all subclasses in a particular family will share some common implementation of functionality, that would normaly be a good case for an abstract class, since you need the same implementation of the same functionality in many places. One way to cover your bases - if in doubt, write code for both. ------------------ "One good thing about music - when it hits, you feel no pain" Bob Marley
"One good thing about music - when it hits, you feel no pain" <P>Bob Marley
Joined: Dec 23, 2000
Thanks Michael for the wonderfuk explaination. regds sunil.