A Late Shout-Out to Head First Design Patterns

Literature, Programming, Technology
Head First Design Patterns cover

After years of starting and never completing, I finally finished reading this book. I have been an advocate of software design patterns and principles for some time, but I never took the time to make sure I had a good vocabulary and solid overview of these concepts. Now, I hope I can help talk about good solutions with a common set of tools that modern-day programmers value.

Even though it talks about older Java, all of the concepts are still relevant today. There are old Java references to the Swing API, from which you should upgrade to JavaFX, by the way. It also talk about Java RMI, which I think is still a thing. The Jakarta servlets and JSPs may be slightly antiquated.

It is certainly a provocatively-written book, which you are warned at the beginning. The best and worst aspects of humans are showcased in the scenarios depicted. It is hard to say if most books should be written like this. Regardless, core concepts are ingrained upon reading.

My takeaway is that decoupling is the key. Rely more on defining relationships with interfaces and composition over inheritance. The “coupling” they speak of pertains to a class relying on too many concrete classes and their specific implementations. Instead, the more you allow classes to define their own implementation enforced via interfaces and rely on properties that have instances instead of inherited behaviors, then the more your classes can expect a wider variety of behaviors and be more flexible, as opposed to expecting specific implementation and become more rigid.

I have been a long-time fan of the Laravel framework for PHP and I’m glad to have a more coherent way of talking about the wonderful ways it exemplifies adapters, facades, factories, observers, and why dependency inversion is important.

Not quite an expert on it, by any means, but I do think that the term “dependency inversion” is inevitably confusing. It’s referring to inverting a certain way of thinking, but so often programmers are first introduced to this particular concept, so they are just now being instructed on how concrete classes should rely on abstractions. Their expectations of dependency are not “inverted”, they are just now trying to understand the best approach.

The book does a great job encouraging the reader to follow up with Design Patterns: Elements of Reusable Object Oriented Software as the initial starting place that it wants to prepare you for.

I’m very inspired to go through my library and find things that I’ve been strongly encouraged to read and kept putting off. Do not procrastinate on this one. Please read this book at your earliest convenience.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.