This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
Felix, You use an interface when you are defining a contract for the class. For example, "all Display objects will implement print()."
You use an abstract class when you want to provide some base functionality. You also use an abstract class when you want to provide a template and the caller just has to fill in a few methods that get called in the middle.
I use abstract classes that don't contain a single non-abstract method as well because some classes will always be only one thing and are never going to be another at the same time. I use abstract classes in this case in order to minimize the sources of bugs and bad design (classes that do too much).
Jeroen Wenting
Ranch Hand
Joined: Oct 12, 2000
Posts: 5093
posted
0
once you understand the different concepts ruling abstract classes and interfaces you'll know when to use which...
An interface defines a contract the implementing class promises to abide by. An abstract class tells you that the extending class IS something.