JavaRush /Java Blog /Random EN /Review of the book “Head First Design Patterns”
Alex
Level 37

Review of the book “Head First Design Patterns”

Published in the Random EN group
Among people who are at least minimally familiar with the Head First series, there are many who consider such literature to be rather superficial reading for beginners. What can I say, it is unlikely that you will be able to deeply study a complex topic in the field of programming in 48 hours. However, it's hard to argue that Design Patterns is a book that will be a useful guide to programming for beginners. This book is one of the ten most popular on Stackoverflow, and for good reason. The ease of presentation, the fundamental topic and high-quality examples make the book popular now and, in my opinion, for many years to come. Review of the book “Head First Design Patterns” - 1

Features of the book

Head first design patterns tells us what patterns are, how to use them, and how to think about them. A pattern is a template, a universal solution for a specific set of problems. Design patterns are, in turn, commonly used architectural solutions that can be used to write user-friendly and flexible applications. Developers all over the world solve the same problems with the same approaches. As the annotation says, if you don’t want to reinvent the wheel, use ready-made design templates (patterns), which this book is dedicated to working with . Separately, it is worth noting the presentation of the material: the books in the Head First series are famous for their simplicity and are read in one sitting. “Design Patterns” is no exception. It also adheres to the following key principles:
  1. Visibility
  2. Conversational style of presentation
  3. A large number of illustrations
  4. Active reader participation
  5. Appeal to emotions
  6. Grabbing the reader's attention
The authors of the book competently use the theory of metacognition to present the material: for me, the first 100 pages flew by unnoticed. The beauty of this approach is that the brain actually remembers what it reads. The combination of several narrative styles, interesting questions, redundancy and creativity - all this helps the reader not to lose interest in the main topic. Before purchasing the book, I was hesitant after reading mixed reviews. However, after quickly skimming through several other sources on this topic, I decided: to dive into patterns, this book is what you need.

Main theme and key idea

“Surely someone has already solved your problem” - this is how the first chapter of the book begins, conveying the whole meaning of design patterns in programming. The main goal is to correctly convey their meaning to the reader, because first of all, the programmer must know what the patterns are for and at what point they need to be applied. Essentially, you first need to sort the templates into little pieces in your head, and only after that implement them into programs. If a beginner in programming has a good understanding of patterns, their use can greatly complicate the code (but should simplify it!). To the question “Why should design patterns be used?” The book gives a clear answer: “Knowing concepts like abstraction, inheritance, and polymorphism does not make you a good OO designer. The patterns contain proven OO design experience.”

"Summary"

The book is divided into 14 chapters plus an introduction. At the beginning, the authors of the book try to prepare the reader, to tune his brain to correctly perceive information about pattern design. The first chapter explains the basic principle of patterns and what purposes they serve. One of the most used patterns - strategy - is easily and unobtrusively examined. Chapters two to eleven are devoted to a detailed analysis of individual patterns :
  1. Observer. Distributes events across objects that are interested in their occurrence.
  2. Decorator. Another look at inheritance in Java and giving Java classes new capabilities without modifying the code.
  3. Factory. The pattern saves the code from unwanted dependencies.
  4. Single. Also known as Singleton, it allows you to create a single class object for the entire program.
  5. Team. The pattern allows you to conveniently encapsulate a method call, expanding its capabilities.
  6. Adapter and Facade. Solving the problem of interface incompatibility, as well as packaging objects to simplify their interface.
  7. Template method. Encapsulation of algorithmic blocks, allowing subclasses to associate with the desired processing algorithm at any time.
  8. Iterator and Linker. The pattern provides a convenient tool for iterating through collections, regardless of their type. Additionally, the chapter provides some information about supercollections.
  9. State. Objects are endowed with the ability to control their behavior through changes in their internal state.
  10. Deputy. A very convenient pattern for controlling access to an object.
Chapter 12 examines composite patterns, or rather combinations of some of the patterns discussed, that can be used to build powerful software architectures. Chapter 13 is devoted to the use of patterns in real problems, the classification of patterns, their varieties and guidelines for use are presented. The book serves as an appendix to Chapter 14, which covers a wider range of patterns. Each of them is useful in its own way, so knowing them is more than desirable. Of course, they are not as popular as the patterns from chapters 2-11, but this does not make them any less useful. The book does not pretend to be an academically accurate presentation of pattern theory. But if the Head First books are so meticulous, aspiring developers won't have a chance to figure out what's what and clarify the basics for themselves. This is a simple and convenient way to learn what design patterns are for those who are not familiar with them. According to the authors, Design Patterns is a book that is suitable for those who are already familiar with Java (or C#), want to learn the principles of object-oriented design, and prefer lively conversation to boring lectures. This book is not a reference book! If you are a professional developer with experience and work with at least part of these patterns, the book is unlikely to be of interest to you. An important component of the book is the exercises: you should not skip them. If you carefully read the book and, in extreme cases, do a minimal search on the Internet, solving them will not add headaches to you. But there will definitely be benefits. At the very least, you will understand more deeply the theory that is presented in the book.

Advantages and disadvantages

I, like many of those who study at JavaRush, have a cold attitude towards boring lectures, cramming material and other violence against the psyche of a student thirsty for knowledge. The energy spent on memorizing incomprehensible texts, in my opinion, is best spent on finding alternative sources of learning. This book is one that is worth your time and effort. An excellent presentation style, competent management of the reader’s attention, and repetition of key points form the main advantage of this book - the ease of assimilation of the material . A large number of illustrations is an additional plus. In my opinion, every picture in the book has its place: they all allow you to reinforce the words of the authors and gain a deeper understanding of the essence of the material. As I wrote above, this book is not a reference book: its authors do not intend to list all the patterns. Its main task is to provide understanding and talk about the basic patterns so that other, more complex ones, are easier to understand. And she copes with this 100%. Among the disadvantages is that Head first design patterns in Russian are not as easy to read as in English. Of course, every developer should speak English, but novice programmers do not always develop this skill to such an extent that they can read books in the original. However, this can be considered a forced minus, since the material is presented quite accurately and the meaning is preserved.

Additional books on design patterns

I am a proponent of the belief that it is better to study fundamental topics from several sources and look for a suitable presentation style in them. When you want to dive into patterns and read additional theory, believe me, you will have something to occupy your evenings.
  1. Object-oriented design techniques. Design Patterns (Gamma E., Helm R., Johnson R., Vlissides J.).

    Review of the book “Design Patterns” (Head First Design Patterns) - 2

    This is a more serious publication, a reference book of patterns, a very respected book from the “Gang of Four”. Many call it the bible of OO design.

    On the Internet, the opinions of developers are divided into 3 camps:

    • some argue that the book is outdated and the style of presentation makes it impossible to read
    • others recommend using the book solely as a reference book on patterns, nothing more
    • still others say that the book is the holy grail of design patterns and should be read by anyone who wants to one day become a Senior Java Developer
    I am an adherent of the second group: I think that the book is really worthy, but reading it for development, and not for the purpose of searching for any information, is very difficult.

    Important:The examples in the book are written in C++.

  2. Java EE. Design patterns for professionals (Murat Yener, Alex Fidom).

    Review of the book “Design Patterns” (Head First Design Patterns) - 3

    This book is dedicated to the design of Enterprise applications: it covers many examples of real-life application problems.

  3. Design patterns in Java (Grand M.).

    Review of the book “Design Patterns” (Head First Design Patterns) - 4

    The book colorfully demonstrates how the use of patterns saves developers time, provides an overview of the UML language, and describes 47 design patterns.

Design Patterns in JavaRush

In the JavaRush course, design patterns are learned at level 7 of the Java Collections quest. Lectures 1 and 2 are devoted to the most common patterns, and in Lecture 4 you can solve problems on this topic. Below are some interesting articles to “strengthen yourself”:
  1. A general article on the topic of patterns with categories, examples, everything we like.

  2. Two articles on patterns: part 1 overview and more detailed part 2 .

  3. Design patterns using the Singleton pattern as an example .

  4. Articles about the “ Strategy ” and “ Adapter ” patterns.

  5. The concept of design patterns is related to UML diagrams, this article will help you understand what they are.

Comments
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION