Designing for Reuse - Gregoire Marc (Professional C++, 2018)
A C++ programmer can design code that both he/she and other programmers can reuse. This rule applies not only to libraries and frameworks that you specifically intend for other programmers to use, but also to any class, subsystem, or component that the programmer designed for a program. One of the aspects of designing reusable code, providing ease of use, is more relevant to the interface design. In addition to abstracting and structuring the code appropriately, designing for reuse requires the programmer to focus on the interface with which programmers interact. This chapter provides some specific strategies for designing interfaces that are easy to use. It also presents specific tips for structuring the code: to avoid combining unrelated or logically separate concepts, to use templates for generic data structures and algorithms, to provide appropriate checks and safeguards, and to design for extensibility.