Brief overview of some, common and not so common behavioural design patterns.
|
What is it?
many objects need to be notified of changes in the state of one object
|
|
Where have I seen it before?
RSS feeds or any pub/sub system you might have used/coded
|
|
What problem does it solve?
you want to save the state of an object so that you can restore it later.
|
|
Where have I seen it before?
Git or any version control system for that matter. A memento makes rollbacks possible.
|
|
What problem does it solve?
A language must be parsed and interpreted.
|
|
Where have I seen it before?
Parsers
|
|
Observer: minimal coupling; easy addition and removal of observers
|
|
Memento: it is an encapsulated copy so it avoids exposing its info; the storage burden is on the caretaker, not on originator
|
|
Interpreter: easy to change/extend/implement/evaluate a language
|
|
Observer: Possible memory leak; Objects might need to work hard to deduce what changed in the subject.
|
|
Memento: Copy operation to a memento can be costly for the originator; Caretaker might have large storage costs.
|
|
Interpreter: Complex grammars are hard to maintain and debug.
|
No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.