Summary: Provide three “classes”: an interface, an abstract class, and a default implementation. [Design Pattern] Context You are developing a framework of cooperating classes. Forces You want to make things easy for the user, so you want to provide implementations. But you want your design clean, and you want the user to provide implementations where […]
Author: Bill Wake
Separate allocation and initialization: provide them as separate operations rather than as a joint operation. [Low-level Design Pattern] Context You’re creating an object based on an external data structure. Part of the job is to create your object, and part is to populate it with the information from the external structure. Forces We want to […]
Make expensive operations cheaper using a quick-and-dirty check. [Low-level Design Pattern] Context Performance is important. Forces You have a time-consuming operation. If only …, the operations wouldn’t be so expensive. Resolution Develop two versions of the operation: one that handles all complications, and another that deals with a common simple case. Devise a quick-and-dirty check […]
Pattern Patter: Post-Process Binaries
Summary: Add capabilities to a language without extending the language. [Architecture Pattern] Example You may have a source language that doesn’t provide a particular capability. You can’t or won’t change the source language. (Perhaps you can’t change the language; perhaps making the user recompile just to acquire that capability is too time-consuming.) Forces You want […]
Summary: Allow languages without default parameters to simulate their use. [Code Pattern] Example You want to provide a method to open a file. You always need a filename, but you might have other parameters you occasionally use to specify things like buffering. C++ allows for default parameters to specify a value for when the parameter […]
Summary: This is a pair of code patterns for dealing with the dependencies between a subclass and a superclass caused by constructors, and for creating only one copy of a class. Designated Initializer Example It’s easy to have an unexpected constructor be called. class A { A() {System.out.print(“A(); “);} A(String s) {System.out.print(“A(“+s+”); “);} } class […]
Summary: This pair of patterns is inspired by some of the design decisions in the Java class library. Marker Class AKA Tagging Class Example: You would like to have all objects provide a clone method. This is a generally useful facility, so you want it high in the hierarchy, but it’s potentially an expensive method, […]
Summary: This set of structural patterns deals with resolving the pressures caused by an attribute that turns out to have multiple occurrences. Motivation When we want to keep track of an attribute of an object, deeper analysis often reveals that the attribute occurs multiple times, or takes on different values over time. For example, in […]
Pattern Patter: Resources
Summary: There are many resources for people interested in patterns. This month, I’ll review some of the more important ones. On the Web http://billwake.blogspot.com/search/label/patterns My patterns home page. http://st-www.cs.uiuc.edu/users/patterns/The Patterns Home Page. These are the basic patterns pages, hosted by UIUC. http://www.bell-labs.com/cgi-user/OrgPatterns/OrgPatternsThe Organizational Patterns Page. Patterns for software engineering in the large. http://c2.com/ppr/Portland Pattern Repository. […]
Publications (as of 1995)
William C. Wake. “Patterns for Interactive Applications”. Submitted for CACM, Oct., 1996 special issue on patterns. [Rejected] William C. Wake. A Model and Interface for Documents with Multiple Views. PhD Dissertation, Department of Computer Science, Virginia Polytechnic Institute and State University, Blacksburg, VA. In progress. [No longer in progress] William C. Wake, B. Douglas Wake, and […]