Which pattern, when
medium 45 minA pattern is an answer to one kind of pressure.
Watch lesson4:38
Chapter mnemonic
Three design-pattern families
Make the puppets. Fit the strings. Put on the show.
Which family covers fitting existing objects together?
Structural patterns. Creational patterns make objects and behavioral patterns coordinate them.
Remember it
The few things worth knowing cold, and how to make them stick.
Memory hook
Read the lock, then pick the key.
A caretaker's ring: every lock shape has its key, a door with only a handle needs none, and twenty keys for a shed make you tired.
Cheat sheet
- Rule chosen outside
- Strategy
- Behaviour by phase
- State, or a table
- Open list of receivers
- Observer
- Class known at run time
- Factory
- Undo, queue, log
- Command
- Extras in any mix
- Decorator
- Wrong interface
- Adapter
- Any link may stop
- Chain
- Only a number differs
- no pattern
Spot it when you see
- A rule that changes often
- The same call with another meaning
- More receivers later
- Undo or history
- A foreign library
Tricks that stick
- FPCE: Force, Pattern, Cost, Exit.
- Adapter translates, Decorator adds, Proxy controls.
- Strategy is chosen, State moves on.
Do not forget
- Naming patterns before forces
- Singleton because there is one
- A class where a number would do
- An interface with one class and no plan
- Listeners called before the change is done