Abstract classes are classes that cannot be instantiated and are partially implemented or not implemented. Members that are implemented can still be overridden in the implementation class. A class can only inherit only one abstract class or any other type of class. Abstract classes provide elements of inheritance and interface.
Interfaces are definitions how a class needs to respond. An interface describes methods, properties (applicable to Visual Basic .Net) and events that a class needs to implement and type of parameters each member receive and return, but leaves the specific implementation of these members up to the implementing classes. A class may implement more then one interface.
The choice of whether to design an abstract class or an interface sometimes can be difficult. Both interface and abstract class is useful for component integration. Some points that help you to whether to choose an abstract class or interface
- If you are creating multiple versions of component then use abstract class. By updating the base class all the inheriting classes are automatically updated with changes. Interfaces cannot be changed once they are created. If new version of interface is required, you must create a new version of interface.
- If the functionality you are creating will be useful across a wide range of disparate objects, use an interface.
- Abstract classes should be use for primarily for objects that are closely related whereas interfaces are used where common functionality is required to unrelated classes.
- If you are designing small, concise bits of functionality, use interfaces. If you are designing large functional units, use an abstract class.
- If you want to provide common, implemented functionality among all implementations of your component, use an abstract class. Abstract classes allow you to partially implement your class, whereas interfaces contain no implementation for any members