Head First Design Patterns

Head First Design Patterns

You're not alone.

At any given moment, somewhere in the world someone struggles with the same software design problems you have. You know you don't want to reinvent the wheel (or worse, a flat tire), so you look to Design Patterns — the lessons learned by those who've faced the same problems. With Design Patterns, you get to take advantage of the best practices and experience of others, so that you can spend your time on...something else. Something more challenging. Something more complex. Something more fun.

If you've read a Head First book, you know what to expect — a visually-rich format designed for the way your brain works. Using the latest research in neurobiology, cognitive science, and learning theory, Head First Design Patterns will load patterns into your brain in a way that sticks. In a way that lets you put them to work immediately. In a way that makes you better at solving software design problems, and better at speaking the language of patterns with others on your team.

A collection of images from inside the book.

Read Me:
What you should know before reading this book

We use simple UML-like diagrams.

Although there's a good chance you've run across UML, it's not covered in the book, and it's not a prerequisite for the book. If you've never seen UML before, don't worry, we'll give you a few pointers along the way. So in other words, you won't have to worry about Design Patterns and UML at the same time. Our diagrams are �UML-like� -- while we try to be true to UML there are times we bend the rules a bit, usually for our own selfi sh artistic reasons.

We don't cover every single Design Pattern ever created.

There are a lot of Design Patterns: The original foundational patterns (known as the GoF patterns), Sun's J2EE patterns, JSP patterns, architectural patterns, game design patterns and a lot more. But our goal was to make sure the book weighed less than the person reading it, so we don't cover them all here. Our focus is on the core patterns that matter from the original GoF patterns, and making sure that you really, truly, deeply understand how and when to use them. You will fi nd a brief look at some of the other patterns (the ones you're far less likely to use) in the appendix. In any case, once you're done with Head First Design Patterns, you'll be able to pick up any pattern catalog and get up to speed quickly.

The activities are NOT optional.

The exercises and activities are not add-ons; they're part of the core content of the book. Some of them are to help with memory, some for understanding, and some to help you apply what you've learned. Don't skip the exercises. The crossword puzzles are the only things you don't have to do, but they're good for giving your brain a chance to think about the words from a different context.

We use the word "composition" in the general OO sense, which is more fl exible than the strict UML use of "composition".

When we say �one object is composed with another object� we mean that they are related by a HAS-A relationship. Our use refl ects the traditional use of the term and is the one used in the GoF text (you'll learn what that is later). More recently, UML has refi ned this term into several types of composition. If you are an UML expert, you'll still be able to read the book and you should be able to easily map the use of composition to more refi ned terms as you read.

Book code and downloads

  • Download the Java code here (zip file).
    The source files are in the src directory and the class files are in the bin directory.
  • Download the MVC song here.
  • Download README.txt. This has all the command line run commands for each application, as well as helpful comments.
  • Download the heatindex.txt file containing the heat index formula for the Weather Station in chapter 2.
  • Download the test.txt file for chapter 3
  • If you are using ant to compile the java files, you can download the build.xml file. (Make sure you name this file "build.xml" to use it with ant.)
  • Download the code examples in C# here (hosted and supported by Mark McFadden).
  • Download the code examples in C++ here (created and supported by Glenn Puchtel).




Interviews and Discussions

Design MeditationsDesign Patterns Guru

Get your daily dose of design sense with Design Meditations


Form your own Head First Patterns Study Group

Sure, you can pick up a book on design patterns, breeze through it, and think you've learned something, but we all know patterns and object-oriented design are deep topics. Like most complex subjects, patterns are best learned over a period of time, not in a few sittings.

Form your own Patterns Group Truly understanding patterns also requires a lot of thought, insight into the true intent of each pattern, comparing and contrasting a set of patterns, and considering the trade-offs in using the pattern (not to mention understanding the basic OO principles behind each pattern). Sometimes it also helps to have a helping hand to get you over those little humps of understanding that are, for the moment, just beyond your reach.


(opens a new window)

Read it on Safari

(opens a new window)

Buy 2 books, get 1 free!

Buy 2 books and get the third free! Use the coupon code OPC10 when you check out.

Who is this book for?

If you can answer "yes" to all of these:

  • Do you know Java? (You don't need to be a guru.)

  • (You'll probably be Ok if you know C# instead.)
  • Do you want to learn, understand, remember, and apply design patterns, including the OO design principles upon which design patterns are based?
  • Do you prefer stimulating dinner party conversation to dry, dull, academic lectures?

You should probably back away from this book if you can answer "yes" to any of these:

  • Are you completely new to Java?
  • (You don't need to be advanced, and even if you don't know Java, but you know C#, you'll probably understand at least 80% of the code examples. You also might be okay with just a C++ background.)
  • Are you a kick-butt OO designer/developer looking for a reference book?
  • Are you an architect looking for enterprise design patterns?
  • Are you afraid to try something different? Would you rather have a root canal than mix stripes with plaid? Do you believe that a technical book can't be serious if Java components are anthropomorphized?
Jolt Award

Head First Design Patterns has taken home the Jolt product excellence award in the general category, beating out some stiff competition like Joel on Software by Joel Splosky. One of our favorite books won the technical category: Better, Faster, Lighter Java by Bruce A. Tate and Justin Gehtland. Congrats Bruce and Justin!


Also by Kathy Sierra & Bert Bates

Head First Java

Head First Java