Design Patterns & Smells
notes
it seems like "design patterns" are not exclusively restricted to 'object-oriented-programming', but this is the context in which I have learned such design.
there are three main categories of Design Patterns as decreed by the 'Gang of Four'1 (the authors of a seminal work Design Patterns | Elements of Reusable Object-Oriented Sofware.
- Creational Patterns
- Structural Patterns
- Behavioural Patterns
in turn, each of these contain more patterns:
-
Creational:
- Factory Method
- Abstract Factory
- Builder
- Prototype
- Singleton
-
Structural
- Adapter
- Bridge
- Composite
- Decorator
- Façade
- Flyweight
- Proxy
-
Behavioural:
- Interpreter
- Template Method
- Chain of Responsibility
- Command
- Iterator
- Mediator
- Memento
- Observer
- State
- Strategy
- Visitor
because these patterns tend to be solutions to bad design smells, I've decided to include all the details on a single page.
design smells
duplicated code
long method
large class
long parameter list
divergent change
shotgun surgery
feature envy
data clumps
primitive obsession
switch statements
parallel inheritance hierarchies
lazy class
speculative generality
temporary field
message chains
middle man
inappropriate intimacy
alternative classes with different interfaces
incomplete library class
data class
refused bequest
comments
comments are good, but sometimes they are used as deoderant for bad code!
Footnotes
1
Ralph Johnson, Richard Helm, Erich Gamma, and John Vlissides.