Design Patterns: Elements of Reusable Object-Oriented Software by ErichGamma, RichardHelm, RalphJohnson, and JohnVlissides (the GangOfFour - GoF) ISBN 978-0201633610 , ISBN 0-201-63361-2 Publisher: AddisonWesley Professional (November 10, 1994).
Understanding design patters can dramatically improve your programmng sklls. The GoF state two important principles of object oriented design:
- Program to an interface and not to an implementation.
- Favor object composition over class inheritance.
C++ code from that book can be downloaded from Hillside Group's webpage:
C++ Code download: http://hillside.net/patterns/DPBook/Source.html
You shall not overuse inheritance - white-box reuse. Composition - black-box reuse is an alternative to class inheritance. Composition means that objects work together creating complex functionality. Example a class (object) gets access to another class (object) at run time through its constructor and not via class inheritance (at compile time).
So try to balance the mix of class inheritance and composition. That makes your classes more flexible and the class hierarchy simpler.
Design your interface carefully. As a result the physical implementation will be more efficient and easier to update / refactor to future needs.
Related - On Refactoring C++ Code:
Andrei Alexandrescu Modern C++ Design: Generic Programming and Design Patterns Applied Addison Wesley Professional