You are previewing API Design for C++.
O'Reilly logo
API Design for C++

Book Description

API Design for C++ provides a comprehensive discussion of Application Programming Interface (API) development, from initial design through implementation, testing, documentation, release, versioning, maintenance, and deprecation. The book focuses on the issues of designing APIs for a single language (C++), which remains one of the most widely used programming languages for large software projects.
The book also covers specialized API topics, such as creating scripting and plug-in APIs, with emphasis on API design. A discussion on testing strategies concentrates on automated API testing techniques rather than attempting to include end-user application testing techniques such as GUI testing, system testing, or manual testing.
The book will be helpful to new programmers who understand the fundamentals of C++ and who want to advance their design skills, as well as senior engineers and software architects seeking to gain new expertise to complement their existing talents. Three specific groups of readers are targeted: practicing software engineers and architects, technical managers, and students and educators.

  • The only book that teaches the strategies of C++ API development, including design, versioning, documentation, testing, scripting, and extensibility.
  • Extensive code examples illustrate each concept, with fully functional examples and working source code for experimentation available online.
  • Covers various API styles and patterns with a focus on practical and efficient designs for large-scale long-term projects.

Table of Contents

  1. Cover image
  2. Title page
  3. Table of Contents
  4. Copyright
  5. Foreword
  6. Preface
    1. Why you should read this book
    2. Who is the target audience
    3. Focusing on C++
    4. Conventions
    5. Book web site
  7. Acknowledgments
  8. Author Biography
  9. Chapter 1. Introduction
    1. Publisher Summary
    2. 1.1 What are Application Programming Interfaces?
    3. 1.2 What's Different About API Design?
    4. 1.3 Why Should you Use APIs?
    5. 1.4 When Should you Avoid APIs?
    6. 1.5 API Examples
    7. 1.6 File Formats and Network Protocols
    8. 1.7 About this Book
  10. Chapter 2. Qualities
    1. Publisher Summary
    2. 2.1 Model the Problem Domain
    3. 2.2 Hide Implementation Details
    4. 2.3 Minimally Complete
    5. 2.4 Easy to Use
    6. 2.5 Loosely Coupled
    7. 2.6 Stable, documented, and tested
  11. Chapter 3. Patterns
    1. Publisher Summary
    2. 3.1 Pimpl Idiom
    3. 3.2 Singleton
    4. 3.3 Factory Methods
    5. 3.4 API Wrapping Patterns
    6. 3.5 Observer Pattern
  12. Chapter 4. Design
    1. Publisher Summary
    2. 4.1 A Case for Good Design
    3. 4.2 Gathering Functional Requirements
    4. 4.3 Creating Use Cases
    5. 4.4 Elements of Api Design
    6. 4.5 Architecture Design
    7. 4.6 Class Design
    8. 4.7 Function Design
  13. Chapter 5. Styles
    1. Publisher Summary
    2. 5.1 Flat C APIs
    3. 5.2 Object-oriented C++ APIs
    4. 5.3 Template-based APIs
    5. 5.4 Data-driven APIs
  14. Chapter 6. C++ Usage
    1. Publisher Summary
    2. 6.1 Namespaces
    3. 6.2 Constructors and Assignment
    4. 6.3 Const Correctness
    5. 6.4 Templates
    6. 6.5 Operator Overloading
    7. 6.6 Function Parameters
    8. 6.7 Avoid #define for Constants
    9. 6.8 Avoid Using Friends
    10. 6.9 Exporting Symbols
    11. 6.10 Coding Conventions
  15. Chapter 7. Performance
    1. Publisher Summary
    2. 7.1 Pass Input Arguments by Const Reference
    3. 7.2 Minimize #include Dependencies
    4. 7.3 Declaring Constants
    5. 7.4 Initialization Lists
    6. 7.5 Memory Optimization
    7. 7.6 Don’t Inline Until You Need To
    8. 7.7 Copy on Write
    9. 7.8 Iterating Over Elements
    10. 7.9 Performance Analysis
  16. Chapter 8. Versioning
    1. Publisher Summary
    2. 8.1 Version Numbers
    3. 8.2 Software Branching Strategies
    4. 8.3 Life Cycle of an API
    5. 8.4 Levels of Compatibility
    6. 8.5 How to Maintain Backward Compatibility
    7. 8.6 API Reviews
  17. Chapter 9. Documentation
    1. Publisher Summary
    2. 9.1 Reasons to Write Documentation
    3. 9.2 Types of Documentation
    4. 9.3 Documentation Usability
    5. 9.4 Using Doxygen
  18. Chapter 10. Testing
    1. Publisher Summary
    2. 10.1 Reasons to Write Tests
    3. 10.2 Types of API Testing
    4. 10.3 Writing Good Tests
    5. 10.4 Writing Testable Code
    6. 10.5 Automated Testing Tools
  19. Chapter 11. Scripting
    1. Publisher Summary
    2. 11.1 Adding Script Bindings
    3. 11.2 Script-binding Technologies
    4. 11.3 Adding Python Bindings With Boost Python
    5. 11.4 Adding Ruby Bindings With Swig
  20. Chapter 12. Extensibility
    1. Publisher Summary
    2. 12.1 Extending Via Plugins
    3. 12.2 Extending Via Inheritance
    4. 12.3 Extending Via Templates
  21. Appendix A. Libraries
    1. A.1 Static Versus Dynamic Libraries
    2. A.2 Libraries on Windows
    3. A.3 Libraries on Linux
    4. A.4 Libraries on Mac Os X
  22. Bibliography
  23. Index