When to use an Abstract Class And an Interface?
>> Sunday, May 29, 2011
Abstract:In case where you want to use implementation inheritance then it is
usually provided by an abstract base class. Abstract classes are excellent candidates inside of application
frameworks. Abstract classes let you define some default behavior and force subclasses to provide any specific
behavior.
Inheritance: For polymorphic interface inheritance, where the client wants to only deal with a
type and does not care about the actual implementation use interfaces. If you need to change your design
frequently, you should prefer using interface to abstract. CO Coding to an interface reduces coupling and
interface inheritance can achieve code reuse with the help of object composition
usually provided by an abstract base class. Abstract classes are excellent candidates inside of application
frameworks. Abstract classes let you define some default behavior and force subclasses to provide any specific
behavior.
Inheritance: For polymorphic interface inheritance, where the client wants to only deal with a
type and does not care about the actual implementation use interfaces. If you need to change your design
frequently, you should prefer using interface to abstract. CO Coding to an interface reduces coupling and
interface inheritance can achieve code reuse with the help of object composition