It would stand to reason that, in software design, the biggest problems would revolve around new issues that no one has ever encountered before. The truth, however, is that most developers tend to run into the same problems -- and make the same mistakes -- again and again. That's what sparked programmers to create software design patterns that the community at large could embrace as standardized and reusable solutions to common development roadblocks.
For decades, the software development community has created a wealth of these generally-accepted patterns, such as those established by the famed "Gang of Four" -- Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides -- in their 1994 book titled Design Patterns: Elements of Reusable Object-Oriented Software. Unfortunately, putting these patterns to use in an effective manner doesn't just require knowing the details behind each one, but also an understanding of why these patterns exist and the reasons they matter.
In Head First Design Patterns, 2nd edition, authors Elisabeth Robson and Eric Freeman took a deep dive into the various principles and techniques associated with these problem-solving design patterns, specifically aimed at those new to the realm of object-oriented programming. The goal, they said, was to give developers a different perspective on code-structuring habits, all with a focus on proper object-oriented design.
In this Q&A, Robson and Freeman discuss the critical importance of understanding not just the software design patterns themselves, but understanding the underlying object-oriented principles that form the foundation of these patterns. They also discuss who they wanted to reach through this book, their motivations for writing it, and, finally, what they want their readers to take away.
Editor's note: This transcript has been edited for length and clarity.
The book makes great efforts to lay out not just software design patterns in general, but also the philosophy of object-oriented design -- why is this concept so important?
Eric Freeman: As soon as we get into any kind of development effort that's of any complexity, things can get messy very quickly with objects. We don't want our designs to be fragile, breakable or not-reusable; we want them to be maintainable. If we don't have designs that really support those things, that reusability and maintainability, then we're in a world of hurt.
Elisabeth Robson: The whole promise of object-oriented design was so that you could reuse components. Having design patterns and good object-oriented design makes that promise more feasible. Especially as you're dealing with change or different kinds of systems, but you want to reuse components in a way that, like Eric said, is not going to be fragile.
Is there a certain type of developer or level of industry experience that you meant to target with Head First Design Patterns?
Freeman: [The book] is totally appropriate for someone who's a beginner object-oriented programmer -- so they've had an introduction to the basic [object-oriented] concepts. In terms of our audience, we get beginners [as well as] experienced developers who have never had that time to really figure out design patterns to the extent they should have.
Robson: We use Java in the book, so we assume that you know an object-oriented programming language that's similar enough to Java, [and that you] can understand those basic concepts. But we have people from all different kinds of programming backgrounds pick up the book: In fact, we've had readers take our code and translate them into five or six different languages at this point. We definitely tried to make our book as accessible as possible, so you don't have to be an expert in Java to understand the patterns.
In the book, you refer to your readers as "learners" -- can you elaborate on what you mean by that?
Robson: Our book is structured so that readers are building this repertoire of skills as they go, [and] it's meant to be read from beginning to end. We tried to structure [the book] so that we're unfolding these principles about the patterns. Then, we build on those core ideas throughout the book. This way, you get to understand how a principle and a pattern work together in one example. Then, later in the book, you see that [principle] again in a slightly different example of a different pattern.
After reading your book, what do you want your readers to walk away with?
Freeman: We want to build that repertoire of patterns in their head. That doesn't mean they know every detail, but they know enough that as they're approaching a problem. The [design pattern] catalogs are there for a reason -- you don't need to memorize this stuff. But we want our readers to have a good working knowledge of those patterns [and] know that they can go use them.
Robson: [We want them] thinking about the kinds of problems that you'll run into in software design and the various techniques that you can use, along with a deeper way of thinking about object-oriented basics. Building those skills and being ready to explore more [patterns] … and, hopefully, be a better software developer -- that's the goal.