Notes on SOLID
And, finish digesting this:
to finish this below:
1 Five reasons to favor composition over inheritance:
- Java doesn't support multiple inheritance.
- Better testability, easier to mock out the composed element. In order to
test a derived class, you need access to the superclass.
- Both approaches allow you to reuse code, but inheritance breaks
encapsulation. A subclass depending on parent's behavior for its
own is fragile.
- It's more flexible to be able to replace the composed object with another
and better object later.
- Gang of Four, Head First Design Patterns, etc. Smart people
recommend composition over inheritance.