Pages

Saturday, December 7, 2013

Abstract Classes vs. Interfaces

The choice of whether to design your functionality as an interface or an abstract class can sometimes be a difficult one. Some people use abstract classes as a substitute for interfaces, but this is generally considered an anti-pattern.
Interfaces and abstract classes are different in that interfaces describe behavior, while abstract classes define partial implementations. Interfaces have the advantage that they can be implemented by any object which provides the necessary method, regardless of what classes that object inherits from. Abstract methods are typically used to provide a partial implementation.

No comments:

Post a Comment