Inheritance for reuse
Breaks encapsulation and liskov subsitution
See example of Stack inheriting from Vector in Java
Always refactor to use a wrapper pattern (adpater or decorator)
How it works
A subclass inherits from a class to inherit the behaviours that it can use in it's own new behaviour
Issues
Using an instance of the subclass, also has access to the methods of the super class
This can lead to the client using the subclass in ways it was not meant to be use, and possibly causing breaking behaviour
Last updated