Scott Meyers Training Courses
Design Patterns, Templates, and Policy-Based Design

The book Design Patterns by the "Gang of Four" (i.e., the "GOF") introduced the idea of patterns to the software development community. This seminar offers a novel view of design patterns, focusing on how templates can make working with patterns more effective. The seminar also describes policy-based design (PBD), a template-based technology introduced in Andrei Alexandrescu's Modern C++ Design that can generate dozens of implementations for the same pattern, each embodying a unique set of design trade-offs.

Course Highlights

Participants will gain:
  • A knowledge of which pattern names are most important to know.
  • Familiarity with a number of common design patterns, including less frequently known variations.
  • An understanding of how template technology can be used to help generate pattern implementations.
  • A familiarity with the implementation and application of policy-based design.

Who Should Attend

Systems designers, programmers, and technical managers involved in the design, implementation, and maintenance of software systems written in C++. Participants should know the basic features of C++ (e.g., classes, inheritance, virtual functions, templates), but expertise is not required. People who have learned C++ recently, as well as people who have been programming in C++ for many years, will come away from this seminar with new insights into C++, templates, and design patterns.

Format

Lecture and question/answer. There are no hands-on exercises, but participants are welcome to use their computers to experiment with the course material as it is presented.

Length

One full day (six to seven lecture hours).

Detailed Topic Outline

  • Brief review of design patterns and programming idioms.
    • Why study design patterns?
    • The most important pattern names to know.
    • Patterns vs. code
      • Common variations in the Factory pattern
  • Visitor and variations:
    • The classic GOF Visitor pattern
    • The Visitor encapsulation problem
      • How the Private Inheritance pattern can address it
    • The Acyclic Visitor pattern, its pros and cons
    • The Ad Hoc Visitor technique:
      • Typelists
      • Template metaprogramming to generate cascading type tests
  • Two views of Observer:
    • Summary of the classic GOF Observer pattern
    • A template-based approach built on tr1::function:
      • Overview of TR1 and Boost
      • Using tr1::function to eliminate the Observer base class
      • Advantages and disadvantages of the approach
  • Singleton and Related Patterns:
    • The classic GOF Singleton pattern, its pros and cons
    • Meyers' variant
    • The Monostate pattern
    • Singleton and thread-safety
      • The Double-Checked Locking pattern and why it's not safe in C++
  • Policy-Based Class Design (PBD):
    • What it is
    • Alexandrescu's PBD approach to Singleton
      • Identification of orthogonal policy issues
      • Implementing policies via templates
      • The Loki library
      • Using policies via template template parameters
      • Pros and cons of this approach
    • PBD and generative programming
  • Further Reading

For more information on this course, contact Scott directly.

Scott Meyers
Software Development Consultant
3051 SW Turner Road
West Linn, OR 97068

Voice: 503-638-6028
Fax: 503-638-6614
Email: smeyers@aristeia.com