October 2004
Intermediate to advanced
240 pages
6h 22m
English
Avoid inheritance taxes: Inheritance is the second-tightest coupling relationship in C++, second only to friendship. Tight coupling is undesirable and should be avoided where possible. Therefore, prefer composition to inheritance unless you know that the latter truly benefits your design.
Inheritance is often overused, even by experienced developers. A sound rule of software engineering is to minimize coupling: If a relationship can be expressed in more than one way, use the weakest relationship that’s practical.
Given that inheritance is nearly the strongest relationship we can express in C++, second only to friendship, it’s only really appropriate when there is no equivalent weaker ...