Policy-Based Design and Patterns
A 2-day Intensive Hands-on Workshop
Taught by Scott Meyers & Bruce Eckel
Enrollment is limited to 30 people.
CANCELLED
Please note that this workshop description is subject to change as we
develop these ideas
Policy-Based Design (PBD) is a language-neutral design technique
derived and generalized from Andrei Alexandrescu's work1 on Policy-Based Class Design in
C++. PBD may or may not be a design pattern, which is a subject we'll also
tackle during the workshop (see later on this page). Policy-based design is an
approach to the object-oriented analysis and design of software systems that
emphasizes breaking solutions down into orthogonal policies that can be easily
mixed and matched to build systems with widely varying characteristics.
Originally developed by Alexandrescu to generate pattern implementations using
C++ templates, policy-based design is useful in any object-oriented language.
This workshop offers a chance to work with Scott, Bruce, and the other workshop
participants to develop policy-based designs for a number of problems and to
implement them in the programming language of your choice.
The basic idea of PBD is straightforward, and very
similar to that of Strategy, where you find algorithms or portions of
algorithms that vary, and encapsulate them into classes so they can be easily
changed. Policy-based design is also similar to template method and
abstract factory. Instead of a single method describing an algorithm, as in strategy,
Policy involves a group of methods that together describe a policy for
handling a particular situation. For example:
Issues of creation, lifetime and the threading model of a singleton can be packaged
together into three policies, one for each concern.
The possibilities and processes for creating an invoice and shipping an order can comprise one or more policies.
The rules for determining how you handle security issues make up a security policy.
The PBD presented here is distinct from Alexandrescu's work
in that it is more general; he focuses on applications that are bound at compile
time using C++ templates whereas we are interested in policies that can be
implemented in any programming language and chosen at compile time or at run time.
The structure of PBD is quite simple and thus can easily be implemented in
any language. The challenge that we will tackle during this workshop is the
process of discovering how policies can be represented in your system and then
decomposing your area of variance into a set of policies.
The goal of this exercise-based workshop is to give you a set of tools
to help you design and implement systems using PBD. The learning will come
primarily from hands-on design projects. Each project will begin with an
introduction and discussion led by Scott and Bruce. Next, attendees will break
up into small groups to work on the given design project with Scott and Bruce
circulating among the teams and offering ideas and insights. Lastly, we will
debrief each project with the teams reporting their results for discussion. The
point of the design reviews is the same as the discussions to draw out
the experience and perspectives of the entire group, and enable everyone to
learn from each other.
In addition, we will struggle with the issue of whether PBD is actually a
design pattern, and if so, attempt to write up PBD in pattern form. Questions
can include:
- Is it a manifestation of template method?
- Or is it a variation of strategy, at least bearing similarities to the structure of strategy?
- How important is the distinction between run-time polymorphism and so-called
"compile-time polymorphism" (as implemented by templates)?
This workshop is not language-specific; it is open to persons with backgrounds
in object-oriented programming and design. The goal is to generate (and share)
designs rather than to focus on particular language implementation details. You may choose
to implement your designs in C++, Java, C#, Delphi or Python (Python is the simplest OO language to
use, so you can choose that if you are not familiar with C++ or Java).
- Dramatically increase the flexibility of your designs
- Build in extensibility and reusability
- Learn more about polymorphism, including compile-time polymorphism (i.e. C++ templates, which will be added
in some form to Java and probably to C#)
Prerequisites:
A high degree of comfort with object-oriented terminology. Familiarity with
design patterns. Implementation experience with an object-oriented language.
Recommended Reading (before the workshop):
Design Patterns: Elements of Reusable Object-Oriented
Software, by Gamma et al.
Thinking in Patterns, a preliminary version of which you can find here. (This material
will be evolving over time).
What you should bring:
Your notebook computer with programming language development environment of your
choice loaded and tested.
A willingness to actively participate in group activities.
1
Modern C++ Design: Generic Programming and Design Patterns Applied
by Andrei Alexandrescu (Addison-Wesley 2001), Chapter 1.
2
Design Patterns,
by Gamma, Helm, Johnson & Vlissides (Addison-Wesley 1995).