Slide 22
Slide 22 text
TRADEOFFS, TRADEOFFS EVERYWHERE…
PROS & CONS!
▸ Inheritance specifies the Domain in terms of semantics (focus on “what it is”)
▸ Composition allows the Domain to be flexible in terms of behaviors (focus on
“what it does”)
▸ Inheritance is good for fixed, well-specified hierarchies (UI), but forces design
early on
▸ Composition helps with “the same, but different” (business reqs.) and allows for
supple design
▸ Inheritance is easy to (involuntarily) abuse, mixing different concerns and coupling
unrelated behaviors, becoming harder to reason about (and test)
▸ Composition is more explicit and, focusing on small and single-responsibility
objects, remains easier to reason about (and test)
(So yeah, not many tradeoffs: composition is almost always preferable)