The book contains catalog of 23 popular programming patterns. There are four authors of this book, sometimes community calls them Gang of Four (GoF).
“Design Patterns” definitely harder to understand than previous two books I wrote in this blog (“Clean Code” and “Code Complete”). Because working with patterns requires lots of abstractions. Fortunately authors made huge work to make everything as clear as possible.
Written in 1994, but that don’t mean nothing in general. Computers will be more powerful than today, new programming languages will be invented, but abstract ideas wrapped in patterns will never die. Note: new programming languages can make implementation of patterns easier.
Sometimes reader can found that he/she knows described pattern, but doesn’t know the name of it. This is one of the aims of the book – make all developers use common vocabulary. It makes life easier:
– Hey, you better put here a Facade.
– Right! Good idea!
The content of the book is strictly cataloged. Every pattern has the name, alternative name, main idea, diagram, sample code, etc. It is very hard to remember all these patterns with details and nuances, therefore this can be excellent handbook.
All examples solve problem of developing text editor application. It makes easier understanding of examples, because during reading the book reader should remember only about one program. But sometimes I found better to study examples in Wikipedia and other sources.
Criticism of patterns idea
In lots of books you may read that code should be as simple and clear as possible. Tricky code in most cases is bad code. Paul Graham – founder of Hacker News – wrote:
When I see patterns in my programs, I consider it a sign of trouble. The shape of a program should reflect only the problem it needs to solve. Any other regularity in the code is a sign, to me at least, that I’m using abstractions that aren’t powerful enough – often that I’m generating by hand the expansions of some macro that I need to write.
But some patterns are so simple and logical, it is hard to produce code without them. Also there are situations, where a pattern fits perfectly.
Once I heard thought:
It is great that software developer uses patterns. But even better than this is to use them only in most suitable cases.
Steve McConnell in his book “Code Complete” wrote a section called “A Software Developer’s Reading Plan”. He divided all books into three levels: Introductory, Practitioner and Professional. “Code Complete” was in the list of Introductory level books, while “Design Patterns” is in Professional level. So make your conclusions on your own