Advantages and Disadvantages Of Inheritance
Inheritance
Advantages:
- Method of reuse in which new functionality is obtained by
extending the implementation of an existing object - The generalization class (the superclass) explicitly captures the
common attributes and methods - The specialization class (the subclass) extends the implementation
with additional attributes and methods
Advantages:
- New implementation is easy, since most of it is inherited
- Easy to modify or extend the implementation being reused
- Breaks encapsulation, since it exposes a subclass to implementation details
of its superclass - "White-box" reuse, since internal details of superclasses are often visible to
subclasses - Subclasses may have to be changed if the implementation of the superclass
changes - Implementations inherited from superclasses can not be changed at runtime
