3: Patterns

Abstract

Design patterns offer general solutions to common software design problems. This chapter provides details for various design patterns and C++ idioms that are particularly relevant to application programming interface (API) design. This includes the pimpl idiom, which provides a way to hide all internal details from your public header files. The Singleton pattern provides access to global state. Its implementation in C++ can be tricky, so singleton best practices and thread safety are covered. The Factory Method patterns make up for several limitations of C++ constructors and can be used to hide implementation details for derived classes. Various patterns for wrapping a new API on top of an incompatible or legacy interface ...

Get API Design for C++, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.