So here are the benefits of inheritance:
• Unlike composition, you can pass the subclass into functions expecting the parent class. • Unlike interfaces, you can reuse code from the parent class in the child class.
So, here’s when you want to use inheritance: when you need to instantiate both the parent and child classes and pass them to the same functions. That’s it. That’s the use case.
When to prefer inheritance to composition
from Hillel Wayne ✉️
- Dependencies (coupling) is an important concern to address, but it&...from kbouck
- By replacing integration tests with unit tests, we're losing al...from Computer Things
- I propose that there is one problem chief among them, an impetus fo...from George Hosu
- When software -- or idea-ware for that matter -- fails to be access...from gist.github.com
- Any software is considered free software so long as it upholds the ...from writefreesoftware.org
- Nathan's four Laws of Software: 1. **Software is a gas** ...from Jeff Atwood
- > Any sufficiently complicated [C](https://en.wikipedia.org/wiki...from From Wikipedia, the free
- Ad-hoc validation leads to a phenomenon that the [language-theoreti...from Alexis King