1. Trang chủ
  2. » Công Nghệ Thông Tin

Martin reddy - API design for cplusplus

446 2.4K 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Cấu trúc

  • Cover

  • Front matter

  • Copyright

  • Foreword

  • Preface

    • Why You Should Read this Book

    • Who is the Target Audience

    • Focusing on C++

    • Conventions

    • Book Web Site

  • Acknowledgments

  • Author Biography

  • Introduction

    • What are Application Programming Interfaces?

      • Contracts and Contractors

      • APIs in C++

    • What's Different About Api Design?

    • Why Should you Use APIs?

      • More Robust Code

      • Code Reuse

      • Parallel Development

    • When Should you Avoid APIs?

    • Api Examples

      • Layers of APIs

      • A Real-Life Example

    • File Formats and Network Protocols

    • About this Book

  • Qualities

    • Model the Problem Domain

      • Provide a Good Abstraction

      • Model the Key Objects

    • Hide Implementation Details

      • Physical Hiding: Declaration versus Definition

      • Logical Hiding: Encapsulation

      • Hide Member Variables

      • Hide Implementation Methods

      • Hide Implementation Classes

    • Minimally Complete

      • Don't Overpromise

      • Add Virtual Functions Judiciously

      • Convenience APIs

    • Easy to Use

      • Discoverable

      • Difficult to Misuse

      • Consistent

      • Orthogonal

      • Robust Resource Allocation

      • Platform Independent

    • Loosely Coupled

      • Coupling by Name Only

      • Reducing Class Coupling

      • Intentional Redundancy

      • Manager Classes

      • Callbacks, Observers, and Notifications

        • Callbacks

        • Observers

        • Notifications

    • Stable, Documented, and Tested

  • Patterns

    • Pimpl Idiom

      • Using Pimpl

      • Copy Semantics

      • Pimpl and Smart Pointers

      • Advantages of Pimpl

      • Disadvantages of Pimpl

      • Opaque Pointers in C

    • Singleton

      • Implementing Singletons in

      • Making Singletons Thread Safe

      • Singleton versus Dependency Injection

      • Singleton versus Monostate

      • Singleton versus Session State

    • Factory Methods

      • Abstract Base Classes

      • Simple Factory Example

      • Extensible Factory Example

    • API Wrapping Patterns

      • The Proxy Pattern

      • The Adapter Pattern

      • The Façade Pattern

    • Observer Pattern

      • Model-View-Controller

      • Implementing the Observer Pattern

      • Push versus Pull Observers

  • Design

    • A Case for Good Design

      • Accruing Technical Debt

      • Paying Back the Debt

      • Design for the Long Term

    • Gathering Functional Requirements

      • What Are Functional Requirements?

      • Example Functional Requirements

      • Maintaining the Requirements

    • Creating Use Cases

      • Developing Use Cases

      • Use Case Templates

      • Writing Good Use Cases

      • Requirements and Agile Development

    • Elements of Api Design

    • Architecture Design

      • Developing an Architecture

      • Architecture Constraints

      • Identifying Major Abstractions

      • Inventing Key Objects

      • Architectural Patterns

      • Communicating the Architecture

    • Class Design

      • Object-Oriented Concepts

      • Class Design Options

      • Using Inheritance

      • Liskov Substitution Principle

        • Private Inheritance

        • Composition

      • The Open/Closed Principle

      • The Law of Demeter

      • Class Naming

    • Function Design

      • Function Design Options

      • Function Naming

      • Function Parameters

      • Error Handling

  • Styles

    • Flat C APIs

      • ANSI C Features

      • Benefits of an ANSI C API

      • Writing an API in ANSI C

      • Calling C Functions from

      • Case Study: FMOD C API

    • Object-oriented APIs

      • Advantages of Object-Oriented APIs

      • Disadvantages of Object-Oriented APIs

      • Case Study: FMOD API

    • Template-based APIs

      • An Example Template-Based API

      • Templates versus Macros

      • Advantages of Template-Based APIs

      • Disadvantages of Template-Based APIs

    • Data-driven APIs

      • Data-Driven Web Services

      • Advantages of Data-Driven APIs

      • Disadvantages of Data-Driven APIs

      • Supporting Variant Argument Lists

      • Case Study: FMOD Data-Driven API

  • Usage

    • Namespaces

    • Constructors and Assignment

      • Controlling Compiler-Generated Functions

      • Defining Constructors and Assignment

      • The Explicit Keyword

    • Const Correctness

      • Method Const Correctness

      • Parameter Const Correctness

      • Return Value Const Correctness

    • Templates

      • Template Terminology

      • Implicit Instantiation API Design

      • Explicit Instantiation API Design

    • Operator Overloading

      • Overloadable Operators

      • Free Operators versus Member Operators

      • Adding Operators to a Class

      • Operator Syntax

      • Conversion Operators

    • Function Parameters

      • Pointer versus Reference Parameters

      • Default Arguments

    • Avoid #define for Constants

    • Avoid Using Friends

    • Exporting Symbols

    • Coding Conventions

  • Performance

    • Pass Input Arguments by Const Reference

    • Minimize #include Dependencies

      • Avoid ``Winnebago´´ Headers

      • Forward Declarations

      • Redundant #include Guards

    • Declaring Constants

      • The New constexpr Keyword

    • Initialization Lists

    • Memory Optimization

    • Don't Inline Until You Need To

    • Copy on Write

    • Iterating Over Elements

      • Iterators

      • Random Access

      • Array References

    • Performance Analysis

      • Time-Based Analysis

      • Memory-Based Analysis

      • Multithreading Analysis

  • Versioning

    • Version Numbers

      • Version Number Significance

      • Esoteric Numbering Schemes

      • Creating a Version API

    • Software Branching Strategies

      • Branching Strategies

      • Branching Policies

      • APIs and Parallel Branches

      • File Formats and Parallel Products

    • Life Cycle of an API

    • Levels of Compatibility

      • Backward Compatibility

      • Functional Compatibility

      • Source Compatibility

      • Binary Compatibility

      • Forward Compatibility

    • How to Maintain Backward Compatibility

      • Adding Functionality

      • Changing Functionality

      • Deprecating Functionality

      • Removing Functionality

    • API Reviews

      • The Purpose of API Reviews

      • Prerelease API Reviews

      • Precommit API Reviews

  • Documentation

    • Reasons to Write Documentation

      • Defining Behavior

      • Documenting the Interface's Contract

      • Communicating Behavioral Changes

      • What to Document

    • Types of Documentation

      • Automated API Documentation

      • Overview Documentation

      • Examples and Tutorials

      • Release Notes

      • License Information

    • Documentation Usability

    • Using Doxygen

      • The Configuration File

      • Comment Style and Commands

      • API Comments

      • File Comments

      • Class Comments

      • Method Comments

      • Enum Comments

      • Sample Header with Documentation

  • Testing

    • Reasons to Write Tests

    • Types of Api Testing

      • Unit Testing

      • Integration Testing

      • Performance Testing

    • Writing Good Tests

      • Qualities of a Good Test

      • What to Test

      • Focusing the Testing Effort

      • Working with QA

    • Writing Testable Code

      • Test-Driven Development

      • Stub and Mock Objects

      • Testing Private Code

      • Using Assertions

      • Contract Programming

      • Record and Playback Functionality

      • Supporting Internationalization

    • Automated Testing Tools

      • Test Harnesses

      • Code Coverage

      • Bug Tracking

      • Continuous Build System

  • Scripting

    • Adding Script Bindings

      • Extending versus Embedding

      • Advantages of Scripting

      • Language Compatibility Issues

      • Crossing the Language Barrier

    • Script-binding Technologies

      • Boost Python

      • SWIG

      • Python-SIP

      • COM Automation

      • CORBA

    • Adding Python Bindings With Boost Python

      • Building Boost Python

      • Wrapping a API with Boost Python

      • Constructors

      • Extending the Python API

      • Inheritance in

      • Cross-Language Polymorphism

      • Supporting Iterators

      • Putting It All Together

    • Adding Ruby Bindings With Swig

      • Wrapping a API with SWIG

      • Tuning the Ruby API

      • Constructors

      • Extending the Ruby API

      • Inheritance in

      • Cross-Language Polymorphism

      • Putting It All Together

  • Extensibility

    • Extending Via Plugins

      • Plugin Model Overview

      • Plugin System Design Issues

      • Implementing Plugins in

      • The Plugin API

      • An Example Plugin

      • he Plugin Manager

      • Plugin Versioning

    • Extending Via Inheritance

      • Adding Functionality

      • Modifying Functionality

      • Inheritance and the STL

      • Inheritance and Enums

      • The Visitor Pattern

      • Prohibiting Subclassing

    • Extending Via Templates

      • Policy-Based Templates

      • The Curiously Recurring Template Pattern

  • Libraries

    • Static Versus Dynamic Libraries

      • Static Libraries

      • Dynamic Libraries

      • Dynamic Libraries as Plugins

    • Libraries on Windows

      • Importing and Exporting Functions

      • The DLL Entry Point

      • Creating Libraries on Windows

      • Useful Windows Utilities

      • Loading Plugins on Windows

    • Libraries on Linux

      • Creating Static Libraries on Linux

      • Creating Dynamic Libraries on Linux

      • Shared Library Entry Points

      • Useful Linux Utilities

      • Loading Plugins on Linux

      • Finding Dynamic Libraries at Run Time

    • Libraries on Mac Os X

      • Creating Static Libraries on Mac OS X

      • Creating Dynamic Libraries on Mac OS X

      • Frameworks on Mac OS X

      • Finding Dynamic Libraries at Run Time

  • Bibliography

  • Index

    • A

    • B

    • C

    • D

    • E

    • F

    • G

    • H

    • I

    • J

    • K

    • L

    • M

    • N

    • O

    • P

    • Q

    • R

    • S

    • T

    • U

    • V

    • W

    • X

Nội dung

Đây là quyển sách tiếng anh về lĩnh vực công nghệ thông tin cho sinh viên và những ai có đam mê. Quyển sách này trình về lý thuyết ,phương pháp lập trình cho ngôn ngữ C và C++.

[...]... Linux Kernel API FIGURE 1.3 Architecture diagram for the Second Life Viewer Internal APIs Third Party APIs Language APIs OS APIs 1.5 API examples 15 Table 1.1 List of open- and closed-source APIs used by the Second Life Viewer API Description APR Boost c-ares cURL Expat FMOD FreeGLUT FreeType glh_linear jpeglib KDU libpng llqtwebkit Ogg Vorbis OpenGL openjpeg OpenSSL Quicktime Vivox xmlrpc-epi zlib The... various common APIs, many of which you’ve probably heard of already, to give you an appreciation for how prevalent API development is • Operating System (OS) APIs Every OS must provide a set of standard APIs to allow programs to access OS-level services For example, the POSIX API defines functions such as fork(), getpid(), and kill() for managing UNIX-style processes Microsoft’s Win32 API 12 CHAPTER... many APIs, where some of these can also depend on further APIs This is illustrated in Figure 1.1, which shows an example application that depends directly on the API for three libraries (1–3), where two of those APIs depend on the API for a further two libraries (4 and 5) For instance, an image viewing application may use an API for loading GIF images, and that API may itself be built upon a lower-level... on more than one platform, such as Windows and Mac, they would have to rewrite the user interface code using a different GUI API for each platform or they would have to develop their own in-house cross-platform GUI toolkit However, these days most modern GUI toolkits are available for multiple platforms—including Windows, Mac, and Linux—which makes it far easier to write cross-platform applications As... topic and is, of course, the specific focus of this book I therefore begin by describing various styles of C and C++ APIs that you could adopt in your projects, such as flat C APIs, object-oriented APIs, template-based APIs, and data-driven APIs Chapter 6: C++ Usage Next I discuss various C++ language features that can impact good API design This includes numerous important issues such as good constructor... code based on these APIs looks like 14 CHAPTER 1 Introduction TIP APIs are used everywhere in modern software development, from OS- and language-level APIs to image, audio, graphics, concurrency, network, XML, mathematics, Web browsing, or GUI APIs 1.5.2 A Real-Life Example The aforementioned list of API examples was purposefully arranged by architectural level to show the range of APIs that you might... Electrical and Electronic Engineers (IEEE) Dr Reddy worked for 6 years at Pixar Animation Studios, where he was lead engineer for the studio’s in-house animation system This work involved the design and implementation of various high-performance APIs to support Academy Award-winning and nominated films, such as Finding Nemo, The Incredibles, Cars, Ratatouille, and Wall-E He then took on the role of engineering... Introduction 1.6 FILE FORMATS AND NETWORK PROTOCOLS There are several other forms of communication “contracts” commonly used in computer applications One of the most familiar is the file format This is a way to save in-memory data to a file on disk using a well-known layout of those data For example, the JPEG File Interchange Format (JFIF) is an image file format for exchanging JPEG-encoded imagery, commonly... the case of API development, these are absolutely critical to its success Specifically, some of the key differentiating factors of API development include the following • • • An API is an interface designed for developers, in much the same way that a GUI is an interface designed for end users In fact, it’s been said that an API is a user interface for programmers (Arnold, 2005) As such, your API could... 2008) You must anticipate this in your design A well-designed API can be your organization’s biggest asset Conversely, a poor API can create a support nightmare and even turn your users toward your competitors (Bloch, 2005), just as a buggy or difficult-to-use GUI may force an end user to switch to a different application Multiple applications can share the same API Figure 1.1 showed that a single application . class="bi x0 y0 w0 h0" alt="" API Design for C ++ API Design for C ++ Martin Reddy AMSTERDAM • BOSTON • HEIDELBERG • LONDON NEW YORK • OXFORD • PARIS • SAN DIEGO SAN. need for high-quality API design. This book therefore presents a practical distillation of the techniques and strategies of industrial-strength API design

Ngày đăng: 19/03/2014, 14:11

TỪ KHÓA LIÊN QUAN