ProAnswers.org

When should I use abstract classes and when should I use interfaces?

Use Interfaces when…

• You see that something in your design will change frequently.

• If various implementations only share method signatures then it is better to use Interfaces.

• you need some classes to use some methods which you don’t want to be included in the class, then you go for the interface, which makes it easy to just implement and make use of the methods defined in the interface.

Use Abstract Class when…

• If various implementations are of the same kind and use common behavior or status then abstract class is better to use.

• When you want to provide a generalized form of abstraction and leave the implementation task with the inheriting subclass.

• Abstract classes are an excellent way to create planned inheritance hierarchies. They’re also a good choice for nonleaf classes in class hierarchies.