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...
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:
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:
The context is the situation in which the pattern applies. This should be a recurring situation.
Example: You have a collection of objects.
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.
You need to step through the objects without exposing the collection’s implementation.
The solution is what you’re after: a ...