API Design for C++
By- Martin Reddy, CEO, Code Reddy
The design of application programming interfaces can affect the behavior, capabilities, stability, and ease of use of end-user applications. With this book, you will learn how to design a good API for large-scale long-term projects. With extensive C++ code to illustrate each concept, API Design for C++ covers all of the strategies of world-class API development. Martin Reddy draws on over fifteen years of experience in the software industry to offer in-depth discussions of interface design, documentation, testing, and the advanced topics of scripting and plug-in extensibility. Throughout, he focuses on various API styles and patterns that will allow you to produce elegant and durable libraries.
Audience
All software engineers developing C++ code to be used by other developers, whether via APIs, libraries, device drivers, or other reusable components.
Paperback, 472 Pages
Published: February 2011
Imprint: Morgan Kaufmann
ISBN: 978-0-12-385003-4
Reviews
-
Martin Reddy draws from his experience on large scale, collaborative software projects to present patterns and practices that provide real value to individual developers as well as organizations. API Design for C++explores often overlooked issues, both technical and non- technical, contributing to successful design decisions that produce high quality, robust, and long-lived APIs. - Eric Gregory, Software Architect, Pixar Animation Studios"Intended for programmers with intermediate to advanced skills in the C++ programming language, this guide to the building of useful and robust application programming interfaces (APIs) provides practical instruction for software engineers developing systems on which downstream software engineers depend. The work provides a methodical approach to API design covering solution based API design, performance, versioning, documentation, testing, scripting, extensibility and libraries. The work includes numerous illustrations and code examples and access to additional online resources is provided. Reddy is a software development consultant."-- Book News, Reference & Research
Contents
Foreword
Preface
1. Introduction
What Are Application Programming Interfaces?What's Different about API Design?
Why Should You Use APIs?When Should You Avoid APIs?
API ExamplesFile Formats and Network Protocols
About This Book2. Qualities
Model the Problem DomainHide Implementation Details
Minimally CompleteEasy to Use
Loosely CoupledStable, Documented, and Tested
3. PatternsPimpl Idiom
SingletonFactory Methods
API Wrapping PatternsObserver Pattern
4. DesignA Case for Good Design
Gathering Functional RequirementsCreating Use Cases
Elements of API DesignArchitecture Design
Class DesignFunction Design
5. StylesFlat C APIs
Object-Oriented C++ APIsTemplate-Based APIs
Data-Driven APIs6. C++ Usage
NamespacesConstructors and Assignment
Const CorrectnessTemplates
Operator OverloadingFunction Parameters
Avoid #define for ConstantsAvoid Using Friends
Exporting SymbolsCoding Conventions
7. PerformancePass Input Arguments by Const Reference
Minimize #include DependenciesDeclaring Constants
Initialization ListsMemory Optimization
Don't Inline Until You Need ToCopy on Write
Iterating Over ElementsPerformance Analysis
8. VersioningVersion Numbers
Software Branching StrategiesLife Cycle of an API
Levels of CompatibilityHow to Maintain Backward Compatibility
API Reviews9. Documentation
Reasons to Write DocumentationTypes of Documentation
Documentation UsabilityUsing Doxygen
10. TestingReasons to Write Tests
Types of API TestingWriting Good Tests
Writing Testable CodeAutomated Testing Tools
11. ScriptingAdding Script Bindings
Script-Binding TechnologiesAdding Python Bindings with Boost Python
Adding Ruby Bindings with SWIG12. Extensibility
Extending via PluginsExtending via Inheritance
Extending via TemplatesAppendix A: Libraries
Static versus Dynamic LibrariesLibraries on Windows
Libraries on LinuxLibraries on Mac OS X
BibliographyIndex
