COMP2007-Design patterns Flashcards
Gamma, Helm, Johnson, Vlissides
Gang of four
23 patterns
Defined by
- pattern name
- problem/usage
- solution
- consequences
Intent Aka Motivation Applicability Structure Participants Collaborations Consequences Implementation techniques Known uses Related patterns
Design patterns
Tried and tested solutions for recurring problems in programming
Good patterns
- be as general as poss
- proven solution
You must know
- problem you’re facing
- know design patterns
- understand relationships btwn classes and how to allocate responsibilities to them
Patterns are classified into
Creational - concerned with object construction and the installation process
Structural - concerned with composition of classes/objects: how classes and objects are composed to form larger structures
Behavioural - concerned with the way classes and objects interact/patterns of communication between classes
Interface
Set of methods (and variables) that one class allows other classes to access
A CLASS i n t e r f a c e speaking abstractly is the collection of methods and fields that the class permits other classes to access.
A class implements a given interface by means of the code in its methods
Interface defined by what it does, not how its implemented
Structural patterns
- Adapter
- Bridge
- Composite
- Decorator
- Facade
- Flyweight
- Proxy
Creational patterns
- Factory method
- Abstract factory
- Builder
- Prototype
- Singleton
Behavioural patterns
- Chain of responsibility
- Command
- Interpreter
- Iterator
- Mediator
- Memento
- Observer
- State
- Strategy
- Template method
- Visitor