Applied C++: Practical Techniques for Building Better Software

Book description

"I really like the software engineering advice given here. As the chief engineer/architect for a large development group, I can say with certainty that the advice given in this book about how real-world projects must work is right on the mark."

--Steve Vinoski, coauthor of Advanced CORBA Programming with C++, columnist for C/C++ Users Journal and IEEE Internet Computing, and Chief Architect, IONA Technologies

Applied C++ is a practical, straightforward guide to developing high-quality, maintainable software. It reflects the power of C++, templates, and the Standard Template Library for industrial-strength programming. Whether you are a single developer or work in a large team, the tips and techniques presented in this book will help you improve your language and design skills and show you how to solve substantial problems more effectively.

The authors, drawing on their extensive professional experience, teach largely by example. To illustrate software techniques useful for any application, they develop a toolkit to solve the complex problem of digital image manipulation. By using a concrete, real-world problem and describing exact feature, performance, and extensibility requirements, the authors show you how to leverage existing software components and the tools inherent in C++ to speed development, promote reuse, and deliver successful software products.

Inside Applied C++, you will find:

  • A C++ templates primer

  • Workable coding guidelines and extensive coding examples

  • Quick lists of need-to-know information about Exceptions, Assertions, and Standard Template Library components

  • A technique for effectively using prototypes to move your design from an initial concept to a robust solution

  • A technique for building debugging support into your software without a ton of overhead

  • Thirteen specific techniques to improve the overall performance of your software



  • 0321108949B03212003

    Table of contents

    1. Copyright
      1. Dedication
    2. The C++ In-Depth Series
      1. Titles in the Series
    3. Preface
      1. Intended Audience
      2. How to Use This Book
      3. Conventions We Use
      4. Acknowledgments
    4. 1. Introduction
      1. 1.1. Imaging Basics
        1. 1.1.1 . RGB Images
        2. 1.1.2. HSI Images
      2. 1.2. Summary
    5. 2. A Test Application
      1. 2.1. Image Class Design
      2. 2.2. Thumbnail Class
        1. 2.2.1. Thumbnail Algorithm
      3. 2.3. Implementation
        1. 2.3.1. Image Class
        2. 2.3.2. Thumbnail Class
      4. 2.4. Summary
    6. 3. Design Techniques
      1. 3.1. Memory Allocation
        1. 3.1.1. Why a Memory Allocation Object Is Needed
        2. 3.1.2. Memory Allocation Object Requirements
          1. Why Reference Counting Is Essential
        3. 3.1.3. A Primer on Templates
          1. Converting a Class to Templates
          2. Type Argument Names
          3. class Versus typename
          4. Default Template Arguments
          5. Inline Versus Non-Inline Template Definitions
          6. Template Specialization
          7. Function Templates
          8. Explicit Template Instantiation
        4. 3.1.4. Notations Used in Class Diagrams
        5. 3.1.5. Memory Allocator Object’s Class Hierarchy
          1. apAllocatorBase_<> Class
          2. apAllocator_<> Class
          3. Constructor and Destructor
          4. Allocation
          5. Deallocation
          6. apAlloc<> Class
          7. Assignment Operator and Copy Constructor
          8. Memory Access
          9. Object Duplication
      2. 3.2. Prototyping
        1. 3.2.1. Why Prototyping Works
        2. 3.2.2. Common Fears
        3. 3.2.3. Our Image Framework Prototyping Strategy
        4. 3.2.4. Prototype 1: Simple Image Objects
          1. Summary of Lessons Learned
        5. 3.2.5. Prototype 2: Templated Image Objects
          1. Use of Templates
          2. Handle Class Idiom
          3. RGB Images
          4. Summary of Lessons Learned
        6. 3.2.6. Prototype 3: Separating Storage from Image Objects
          1. Design for Partitioning Image Storage
          2. Evolution of the Design
          3. Image Storage Rep Objects
          4. Image Storage Handle Objects
          5. Summary of Lessons Learned
      3. 3.3. Summary
    7. 4. Design Considerations
      1. 4.1. Coding Guidelines
        1. 4.1.1. Changes to Existing Software
        2. 4.1.2. Naming Conventions
        3. 4.1.3. Indentation
        4. 4.1.4. Comments
        5. 4.1.5. Header File Issues
        6. 4.1.6. Restrictions
      2. 4.2. Reusable Code
        1. 4.2.1. The Economics of Reusability
          1. Binary String Class
      3. 4.3. Designing in Debugging Support
        1. 4.3.1. Creating a Generalized Debugging Stream
        2. 4.3.2. Creating Sinks
          1. Flushing a Sink
        3. 4.3.3. Connecting a Sink to a Stream
        4. 4.3.4. Controlling Debugging Output
        5. 4.3.5. Accessing Objects Indirectly Through an Object Registry
      4. 4.4. Summary
    8. 5. System Considerations
      1. 5.1. Multithreaded and Multiprocess Designs
        1. 5.1.1. Threads
        2. 5.1.2. Thread Synchronization
        3. 5.1.3. Processes
      2. 5.2. Exception Handling
        1. 5.2.1. Designing Your Own Exception Framework
        2. 5.2.2. Avoiding Exception Abuse
        3. 5.2.3. Using Assertions
      3. 5.3. Compile-Time Versus Run-Time Issues
        1. 5.3.1. Compiler Issues
        2. 5.3.2. Run-Time Issues
        3. 5.3.3. Template Specialization
      4. 5.4. Coding for Internationalization
        1. 5.4.1. Unicode
        2. 5.4.2. A Simple Resource Manager for Strings
          1. Designing the Resource Manager
          2. Using the Resource Manager
        3. 5.4.3. Saving and Restoring Strings from Files
        4. 5.4.4. An Alternate Approach to Handling Strings
        5. 5.4.5. Locales
      5. 5.5. Summary
    9. 6. Implementation Considerations
      1. 6.1. Finalizing the Image Components
        1. 6.1.1. Image Coordinates
        2. 6.1.2. Image Storage
          1. Final Design
        3. 6.1.3. Pixel Types
          1. Basic Data Types
          2. RGB Data Type
          3. Clamping Object for Overflow
          4. Clamping Functions
          5. Clamping Object
          6. Operators and Mathematical Functions
          7. What’s So Important About Clamping?
      2. 6.2. Finalizing the Image Class
        1. 6.2.1. Image Object
      3. 6.3. Adding Global Image Functions
        1. 6.3.1. Copying an Image
        2. 6.3.2. Processing Single Source Images
        3. 6.3.3. Processing Two Source Images
        4. 6.3.4. Processing Images with Neighborhood Operators
          1. Low-Pass Kernel for Noise Elimination
          2. Laplacian Kernel for Sharpening Edges
          3. High-Pass Kernel for Sharpening Edges
          4. Gaussian Kernel for Smoothing Edges
        5. 6.3.5. Generating Thumbnails
      4. 6.4. Finalizing Interfaces to Third-Party Software
        1. 6.4.1. File Delegates
          1. File Delegate List
          2. JPEG File Delegate
          3. TIFF File Delegate
        2. 6.4.2. Image Delegates
          1. Strategy 1: A Fully Integrated Solution
          2. Strategy 2: A Loosely Coupled Solution
          3. Extending the Loosely Coupled Solution
          4. Our Recommended Strategy
      5. 6.5. Summary
    10. 7. Testing and Performance
      1. 7.1. Unit Tests
        1. 7.1.1. Using the Unit Test Framework
        2. 7.1.2. Design of the Unit Test Framework
          1. apUnitTestFunction Base Class
          2. apUnitTest Object
          3. Macros in the Unit Test Framework
        3. 7.1.3. Extending the Unit Test Framework
      2. 7.2. Performance Tuning
        1. 7.2.1. General Guidelines
        2. 7.2.2. Thirteen Ways to Improve Performance
        3. 7.2.3. Image-Specific Improvements
          1. Execution Results
        4. 7.2.4. A Note About Timing Your Code
      3. 7.3. Summary
    11. 8. Advanced Topics
      1. 8.1. Memory Issues
        1. 8.1.1. Copy on Write
          1. A Practical Solution
        2. 8.1.2. Caching Issues
          1. A General Purpose Caching Framework
          2. Adding a Cache to the Image Object
      2. 8.2. Language Construct Issues
        1. 8.2.1. Explicit Keyword Usage
          1. During Template Instantiation
        2. 8.2.2. Const Usage
          1. Guidelines
        3. 8.2.3. Pass by Reference Usage
          1. Returning a const Reference
          2. Returning a Non-const reference
          3. Passing by const Reference
          4. Passing by Reference
            1. During Template Instantiation
            2. Returning Multiple Values
      3. 8.3. Extending the Framework
        1. 8.3.1. Adding Image Processing Functions
          1. Neighborhood Operations
            1. Morphology
            2. Sobel
          2. Image Space Transforms
          3. Mapping Pixels
          4. Converting Between Color Spaces
        2. Image Geometry
          1. Image Resizing
          2. Image Rotation
        3. 8.3.2. Enhancing Digital Photographs
      4. 8.4. Summary
    12. A. Useful Online Resources
      1. A.1. Software
      2. A.2. Standards
    13. B. CD-ROM Information
      1. B.1. Contents
      2. B.2. Framework
        1. Licensing Information
      3. B.3. Prototypes
        1. Licensing Information
      4. B.4. Utilities
        1. B.4.1. DebugView Utility
          1. Description
        2. Licensing Information
        3. B.4.2. Intel C++ Compiler
          1. Description
          2. Licensing Information
      5. B.5. Delegates
        1. B.5.1. Intel Integrated Performance Primitives (IPP)
          1. Description
          2. Licensing Information
        2. B.5.2. JPEG
          1. Description
          2. Licensing Information
        3. B.5.3. TIFF
          1. Description
          2. License Information
    14. Bibliography

    Product information

    • Title: Applied C++: Practical Techniques for Building Better Software
    • Author(s):
    • Release date: April 2003
    • Publisher(s): Addison-Wesley Professional
    • ISBN: 9780321108944