Don't Inherit Code
The Agile Zone is brought to you in partnership with Hewlett Packard Enterprise. Discover how HP Agile enterprise solutions can help you achieve high predictability and quality in your development processes by knowing the status of your projects at any point in time.
- Uses, in which I care only about your public API;
- Creates, in which I also need to know your class;
- Inherits/extends, in which I can also see some of your workings and I become part of you.
Don’t do that last one. Ever.
Many of the GoF patterns help move code up this list, from tight towards loose coupling. Except TemplateMethod, which not only encourages inheritance, it also creates a circular dependency by having the superclass only “work” in the presence of extensions. Bad.
Don’t inherit code. Bad.