What exactly is a design pattern?
"A bowl of spaghetti looks twisted and tangled, which is where the name for spaghetti code comes from." - Wikipedia |
A design pattern is a potentially reusable solution to many programming problems. In most cases, a programmer is coping with a task, which already had been done by someone else. In my understanding of this term, design patterns were found to help to keep code clear, instead of writing spaghetti code.
Let's face it - everybody writes ugly code sometimes or did that in the past. I think that design patterns may be also a way to write the code you're proud of.
Gang of Four (GOF)
The GoF book. |
A word of warning and encouragement: Don't worry if you don’t understand this book completely on the first reading. We didn’t understand it all on the first writing!
- GoF
There are 23 desing patterns described, divided into 3 groups:
- Creational (C)
- Structural (S)
- Behavioral (B)
It would be hard for me to cover all of them design patterns, so for this blog I'll start with the ones described in the book as "simplest and most common". Here's the list:
- Abstract Factory (C) (theory, full example)
- Adapter (S)
- Composite (S)
- Decorator (S)
- Factory Method (C)
- Observer (B)
- Strategy (B)
- Template Method (B)
Stay tuned, first design pattern examples in Python coming soon!
Brak komentarzy:
Prześlij komentarz