A way to qualitatively learn design patterns


Disclaimer: I am not suggesting that design patterns are absolutely necessary, and that if a person has not read the Gang of Four patterns, then he cannot be called a developer. I just share my experience, how I studied patterns it was me… And I hope that this experience will be useful to someone.

So, to study patterns, I read the following books at the same time:

  1. Head First Edition – Design Patterns

  2. The Gang of Four – Object Oriented Design Techniques. Design patterns

The first book is easy to read, everything is clear; the second book is more difficult to read, it is more technical, but there is also more useful information.

What is the point of reading two books at the same time: you can go sequentially on topics (≈ patterns), first read a chapter from a simple book, and then a chapter on the same topic from a complex one. This approach has the following advantages:

  • More complex information from a complex book is assimilated better due to the fact that you are already prepared to consume this information

  • Information from both books is generally absorbed better by repeating the material and looking at the same problem from different angles

Chapter / topic matching

The authors of the book from Head First do not hide that they took the Gang of Four book as a basis. In particular, the book from Head First discusses exactly the same patterns as in the book from Gang of Four – some more, some less. Thus, it is not very difficult to draw up a correspondence on topics between the two books.

Below I have provided some plan for reading both books (an explanation of how to read this plan is under the plan itself):

# Введения и предисловия

[ ]     Введение
    [ ] Предисловие
    [ ] Введение в паттерны

# Паттерны, хорошо описанные в обеих книгах

    [ ] Предисловие к паттернам поведения
[ ] [ ] Strategy (Стратегия)
[ ] [ ] Observer (Наблюдатель)
    [ ] Предисловие к структурным паттернам
[ ] [ ] Decorator (Декоратор)
    [ ] Предисловие к порождающим паттернам
[ ]     Фабрика (фабричный метод и абстрактная фабрика)
    [ ] Factory Method (Фабричный метод)
    [ ] Abstract Factory (Абстрактная фабрика)
[ ] [ ] Singleton (Одиночка)
[ ] [ ] Command (Команда)
[ ]     Адаптер и фасад
    [ ] Adapter (Адаптер)
    [ ] Facade (Фасад)
[ ] [ ] Template Method (Шаблонный метод)
[ ]     Итератор и компоновщик
    [ ] Iterator (Итератор)
    [ ] Composite (Компоновщик)
[ ] [ ] State (Состояние)
[ ] [ ] Proxy (Заместитель)
[ ]     Составные паттерны
[ ]     Паттерны для лучшей жизни

# Паттерны, хорошо описанные только Бандой Четырех

[ ] [ ] Bridge (Мост)
[ ] [ ] Builder (Строитель)
[ ] [ ] Chain of Responsibility (Цепочка обязанностей)
[ ] [ ] Flyweight (Приспособленец)
    [ ] Обсуждение структурных паттернов
[ ] [ ] Interpreter (Интерпретатор)
[ ] [ ] Mediator (Посредник)
[ ] [ ] Memento (Хранитель)
[ ] [ ] Prototype (Прототип)
    [ ] Обсуждение порождающих паттернов
[ ] [ ] Visitor (Посетитель)
    [ ] Обсуждение паттернов поведения

# Заключения от Банды Четырех

    [ ] Проектирование редактора документов
    [ ] Заключение

Here the title of the chapter / topic corresponds to two columns – the first column means the presence of a chapter / topic in the book from Head First, and the second – in the book of Gang of Four. For example, the topic “Visitor” is in both books, but “Discussion of Patterns of Behavior” is only in the Gang of Four book. The order of the chapters / topics follows the order from Head First.

All topics can be divided into the following groups:

  • Introductions and prefaces

  • Patterns well described in both books. These are the patterns that have stood the test of time and were easily described by Head First

  • Patterns well described only by the Gang of Four. These are less popular patterns, but they also have the right to be studied. Head First devotes literally a few pages to these patterns, while the Gang of Four describes these patterns in the same way as everyone else.

  • Conclusions from the Gang of Four. Here, in addition to the conclusion itself, there is an example of using patterns in practice.

Impressions from books

Head first

The specific cover and the number of pages (600+) for such a seemingly not very serious book can push you away from reading, but in fact the book is read very simply, interesting, sometimes even funny, but at the same time quite useful things are told there. Against the backdrop of the Gang of Four, reading this book almost feels like a rest.

It makes sense to read this book sequentially, not in random order. This is why the order of chapters / topics when reading both books at the same time matches Head First.

The code examples are written in Java.

Gang of four

Unlike Head First, there is no particular order here. The book is more of a reference book of patterns, and there is no need to read it cover to cover. The information here is drier and more technical, but much more details and nuances associated with the implementation and application of both specific patterns and their combinations are considered.

The code examples are written in C ++ and SmallTalk. The latter language, it seemed to me, has a rather specific syntax, but in general you can understand what the authors want to show.

Total

I can suggest 4 ways:

  1. Repeat my path and read both books at the same time. This option is suitable for those who want begin study patterns, but at the same time wants to study them immediately at a fairly good level

  2. Read only a book from the Gang of Four. Suitable for those who already know the patterns quite well and want to study them deeper

  3. Read only the book from Head First. Suitable for those who want to start learning patterns but don’t want to go too deep

  4. Don’t read anything. For who cares about these patterns in the real world?

That’s all. I hope someone will find this article useful, and thanks for your attention!

PS It was not possible to avoid a large number of repetitions of the word “book”, I beg your pardon.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *