-
10:32 Chain of Responsibility
“One way to think about this is like a factory assembly line.”
The chain of responsibility is a way of passing a request between a chain of objects. This pattern creates a chain of receiver objects for a request allowing you to launch and leave requests with a single pipeline with many handlers. The handlers can arbitrarily be reordered.
-
14:52 Command
“It’s basically just a bag of stuff you’re passing on.”
The command pattern encapsulates a command request as an object parameterizing clients with different requests. It is basically an object oriented callback.
-
18:04 Interpreter
“You’ll see this in the guts of compilers…I’ve not had to use this very often.”
Interpreters are a way to include language elements in a program to evaluate language grammar or expression. These include SQL parsing or symbol processing engines.
-
22:59 Iterator
“This basically the thing you use in a for loop.”
Iterator patterns allow you to sequentially access the elements of a collection without exposing the underlying representation. Standard libraries are iterators.
-
29:14 Mediator
The mediator pattern defines a simple communication between classes. It reduces the complexity between multiple objects in a many-to-many relationship and allows for the individual objects to be interchangeable.
-
31:00 Memento
“If you’re sending a command to an object with a memento pattern you would capture the state first.”
Use a memento pattern to capture and restore an object’s internal state. These promote undo or rollback to full object status. This is used heavily in text editors or programs where you need caching.
-
34:50 Null Object
“Null is not a thing, it’s not knowing a thing.”
The null object acts as a default value of an object. Abstract classes specify operations, concrete classes, and a null object class. The are used when the object requires a collaborator or abstract null handling from the client.
-
41:06 Observer
“X observes Y…Y doesn’t have to know what is observing it.”
The observer pattern is a way of notifying changes to a number of objects in a one-to-many relationship. If an object is modified the observer notifies its dependents of the modification.
-
42:58 State
“I used this pattern when I wrote the contact forms for our websites.”
The state pattern alters an object’s behavior when its state is changed. In effect it creates an object-oriented state machine.
-
45:40 Strategy
An algorithm encapsulated in a class is a strategy pattern allowing behavior or algorithms to be changed at runtime. Objects can have various strategies, i.e. a context object’s behavior will vary depending on the strategy object.
-
49:08 Template Method
To defer the exact steps of an algorithm to a subclass use a template method. It creates a skeleton of an algorithm in an operation. The subclasses then may redefine some steps without changing the structure. Base classes declare an algorithm place holder then derived classes implement them.
-
51:42 Visitor
“I’ve used this recently with parsing Odata expressions.”
The visitor pattern defines a new operation to a class without changing the class. This is a classic technique for recovering lost type information.