Book of the Week: Design Patterns
30 Mar 2015
This week, I take a look at Design Patterns: Elements of Reuseable Object-Oriented Software, which is often recommended to new programmers. When you start out as a programmer, your main concern is writing code that accomplishes a task. As you write more and more code, you notice that you need to do the same things over and over again. You notice patterns. Then you begin to isolate and identify things by giving them names. When you starting talking to other programmers, you need some common vocabulary. Design Patterns provides that common vocabulary. 24 Design Patterns Purpose |
Design Pattern | Aspects That Can Vary |
|---|---|---|
| Operation | Abstract Factory | families of product objects |
| Builder | how a composite object gets created | |
| Factory Method | subclass of object that is instantiated | |
| Prototype | class of object that is instantiated | |
| Singleton | the sole instance of a class | |
| Structural | Adapter | interface of an object |
| Bridge | implementation of an object | |
| Composite | structure and composite of an object | |
| Decorator | responsibilities of an object without subclassing | |
| Façade | interface to a subsystem | |
| Flyweight | storage costs of objects | |
| Proxy | how an object is accessed; its location | |
| Behavioral | Chain of Responsibility | object that can fulfill a request |
| Command | when and how a request is fulfilled | |
| Interpreter | grammar and interpretation of a language | |
| Iterator | how an aggregate’s elements are accessed, traversed | |
| Mediator | how and which objects interact with each other | |
| Memento | what private information is stored outside an object, and when | |
| Observer | number of objects that depend on another object; how the dependent objects stay up to date | |
| State | states of an object | |
| Strategy | an algorithm | |
| Template Method | steps of an algorithm | |
| Visitor | operations that can be applied to object(s) without changing their class(es) |
