Abstract Parent Class Pattern

An abstract method is a method that is declared, but contains no implementation. An abstract class is a class with one or more abstract methods. Different subclasses may be designed when the functionality outlined by abstract methods in an abstract class needs to be implemented differently. An abstract class may not be directly instantiated. When a class is designed as a subclass of an abstract class, it must implement all of the abstract methods declared in the parent abstract class. Otherwise the subclass itself becomes an abstract class. The requirement that every concrete subclass of an abstract class must implement all of its abstract methods ensures that the variable part of the functionality will be implemented in a consistent manner in terms of the method signatures. The set of methods implemented by the abstract parent class is automatically inherited by all subclasses. This eliminates the need for redundant implementations of these methods by each subclass.

Using interfaces instead of abstract classes in always an alternative design strategy.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License