Feineigle.com - Design Patterns - Elements of Reusable Object-Oriented Software

Home · Book Reports · 2018 · Design Patterns - Elements of Reusable Object-Oriented Software

Published: September 13, 2018
Tags:  Programming



The book in...
One sentence:
This is the go-to book (colloquially known as the Gang of Four), a catalog of sorts, for learning the origins of software design patterns.

Five sentences:
This book, structured as a catalog describes the original software design patters, most of which are still used today. Its main goal, as it clearly states, is to provide software designers with a common vocabulary so that communication can become more concise. Each section first introduces one of the three main categories of patterns - creational, structural, or behavioral. Next, each section describes, in fair detail, the applicability, the pros, and the cons of each pattern, while also both motivating its use and offering ample sample code. This book, while useful for learning the patterns themselves, shines as the catalog, the dictionary it is laid out as; it is a great resource that allows you to easily skim through the patterns to jog your memory into deciding which pattern may be most applicable to your current problem.

designates my notes. / designates important.


Thoughts

Overall this was a great book. I will keep it in mind as the go-to resource if I ever need a refresher on what pattern I might want to use in a situation where the answer is not obvious.

I really like the layout, with each section offering motivation, theory, structure, example code (in C++ and Smalltalk), and related patterns.

In hindsight I can say that the authors succeeded in their goal of introducing a common language so that developers could communicate at a higher level. 25+ years after its publication it is still a valuable resource and we still use the names the authors assigned to the various patterns.

Chapter one introduces the book itself. What is it? A catalog of design patterns.

Experience shows us that we do a lot of the same things, solving similar problems, again and again. This book tries to put down what those similar solutions look like, describe them, and name them.

The four essential parts of a pattern are its name, what problem it addresses, the solution it offers, and what consequences it has.

There are three main types of patterns, creational, structural, and behavioral. The book is divided into chapters covering each of these high level types.

The old stand-by is reiterated.

Program to an interface not an implementation.

They also see, quite early, that composition is at least as good, and today I think most would agree better, than inheritance.

The authors offer some advice on how to use the catalog, how to choose patterns, and how to go about implementing a pattern. Like some other books I have read, the make a point that name selection based on the context you are working is is absolutely key. In my opinion naming, of functions and variables, is probably the most important aspect of software design.

Chapter two is a case study in the design of a simple document editor that includes such things as glyphs, analysis (spell checking and formatting), layout, and the UI. This is used throughout the book to help motivate several of the patterns. Here it is used to introduce 8 patterns: composition, decorators, strategy, abstract factory, bridge, command, iterator, and visitor.

Chapters three, four, and five are the design pattern catalog.

Chapter three covers the creational patterns, including abstract factories, builders, prototypes, and singletons.

Chapter four covers the structural patterns, including composite, adapter (wrapper), proxy, flyweight, facade, bridge, and decorator.

Most of these patterns are similar/related, but apply to different problems.

For example, the adapter and bridge are almost the same, but used at different points in development. The adapter is used later in development to stick together two things that weren’t foreseen to go together while the bridge sticks them together from the onset, understanding that they will be evolved independently but must work together.

Chapter five covers the behavioral patterns, including chain of responsibility (event handler), command, memento, observer (publish-subscribe), mediator, iterator, interpreter, strategy, template, and visitor.

The state pattern is presented with an example of TCP connections and drawing programs where each tool is a state.

Overall I think this is a must-read for any software developer. Even with its age it is still as relevant today as it has ever been.

On the other hand, I see more functional programming on the horizon, given multi-core processors being the trend that will be followed for the foreseeable future (since we’ve about reached the limit in terms of speed and size for a single core). Still, I think the ideas here are as useful to a functional designer, even if they won’t be implemented in the same way.

Further Reading


Exceptional Excepts

Favor object composition over class inheritance.


Table of Contents


· 01: Introduction

page 15:
page 21:
page 22:
page 23:
page 30:
page 31:
page 32:

· 02: A Case Study: Design a Document Editor

page 43:

Design Pattern Catalog

· 03: Creational Patterns

page 94:
page 120:
page 138:
page 145:

· 04: Structural Patterns

page 155:
page 169:
page 207:
page 208:
page 246:

· 05: Behavioral Patterns

page 249:
page 310:
page 327:
page 342:

· 06: Conclusion

page 393:
page 431: