The Good Stuff Flashcards
What are the best Creational Patterns?
Builder and Object Pool patterns.
What are the best Structural Patterns?
Adapter, Bridge, Composite, Decorator, and Flyweight.
What are the best Behavioral Patterns?
Mediator, State, Visitor, Iterator,
Command, Interpreter, Chain of Responsibility
What are the framework design patterns?
Composite, Command, Interpreter, Chain of Responsibility.
Why is a builder pattern helpful?
provides a single object whose API builds and returns an object Hierarchy to us.
Why is an Adapter Pattern useful?
An Adapter / Wrapper helps when a class doesn’t offer the interface needed. The wrapper can have its methods called on the underlying object.
Why is a Flyweight Pattern useful?
small read-only (immutable) data can be shared between object instances
Example the integers -5 to 256 in Python are flyweight objects. So each time a calculation returns an integer in that range, it’s the same object that gets returned each time.
Why is a Composite Pattern useful?
It gives all nodes in a hierarchy the same interface. We see this with graphic rendering such as the browser DOM.
Why is Chain of Responsibility Useful?
Behavior isn’t lost in a hierarchy. Just as in the browser an event isn’t lost when a child element is clicked on. The event “bubbles” up to the button element and ensure the click event occurs.
Why is the Command Pattern useful?
It represents user actions as a list of objects that have a do() and undo() method. Which is super helpful in browsers and GUI frameworks.
Why is the Interpreter Pattern useful?
It’s like a suped up Abstract Syntax Tree, each node has an executable method.