Chapter 13. Patterns in the Real World: Better Living with Patterns

Ahhhh, now you’re ready for a bright new world filled with Design Patterns. But, before you go opening all those new doors of opportunity, we need to cover a few details that you’ll encounter out in the real world—that’s right, things get a little more complex than they are here in Objectville. Come along, we’ve got a nice guide to help you through the transition on the next page...

Design Pattern defined

We bet you’ve got a pretty good idea of what a pattern is after reading this book. But we’ve never really given a definition for a Design Pattern. Well, you might be a bit surprised by the definition that is in common use:

Note

A Pattern is a solution to a problem in a context.

That’s not the most revealing definition, is it? But don’t worry, we’re going to step through each of these parts: context, problem, and solution:

Note

Example: You have a collection of objects.

  • The context is the situation in which the pattern applies. This should be a recurring situation.

  • The problem refers to the goal you are trying to achieve in this context, but it also refers to any constraints that occur in the context.

  • The solution is what you’re after: a general design that anyone can apply that resolves the goal and set ...

Get Head First Design Patterns, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.