platform when it might actually be cheaper to buy more hardware. If Camel has a greater cost than Swordfish,
and that greater cost is equivalent to a couple of servers, then Swordfish ends up being cheaper even if you
only need 40 tps. It's fashionable to complain about having to rely on better hardware to make our software run
properly, and I join this choir whenever I have to upgrade my laptop just to handle the latest version of Word.
But newer hardware is often cheaper than making software run on less powerful systems. Similarly, adding
more servers is often cheaper than adding more programmers—providing that a system is scalable.
Patterns
Patterns have been around for a long time, so part of me doesn't want to regurgitate their history yet another
time. Still, this is an opportunity for me to provide my view of patterns and what makes them a worthwhile
approach to describing design.
There's no generally accepted definition of a pattern, but perhaps the best place to start is Christopher
Alexander, an inspiration for many pattern enthusiasts: "Each pattern describes a problem which occurs over
and over again in our environment, and then describes the core of the solution to that problem, in such a way
that you can use this solution a million times over, without ever doing it the same way twice" [
Alexander et
al.]. Alexander is an architect, so he was talking about buildings, but the definition works pretty nicely for
software as well. The focus of the pattern is a particular solution, one that's both common and effective in
dealing with one or more recurring problems. Another way of looking at it is that a pattern is a chunk of advice
and the art of creating patterns is to divide up many pieces of advice into relatively independent chunks so that
you can refer to them and discuss them more or less separately.
A key part of patterns is that they're rooted in practice. You find patterns by looking at what people do,
observing things that work, and then looking for the "core of the solution." It isn't an easy process, but once
you've found some good patterns they become a valuable thing. For me their value lies in being able to create
a book that serves as a reference. You don't need to read all of this book, or all of any patterns book, to find it
useful. You just need to read enough to have a sense of what the patterns are, what problems they solve, and
how they solve them. You don't need to know all the details but just enough so that if you run into one of the
problems you can find the pattern in the book. Only then do you need to really understand the pattern in depth.
Once you need the pattern, you have to figure out how to apply it to your circumstances. A key thing about
patterns is that you can never just apply the solution blindly, which is why pattern tools have been such
miserable failures. I like to say that patterns are "half baked," meaning that you always have to finish them off
in the oven of your own project. Every time I use a pattern I tweak it a little here and a little there. You see the
same solution many times over, but it's never exactly the same.
Each pattern is relatively independent, but patterns aren't isolated from each other. Often one pattern leads to
another or one occurs only if another is around. Thus, you'll usually only see
Class Table Inheritance (285) if
there's a
Domain Model (116) in your design. The boundaries between the patterns are naturally fuzzy, but I've
tried to make each pattern as self-standing as I can. If someone says "Use a
Unit of Work (184)," you can look
it up and see how to apply it without having to read the entire book.
If you're an experienced designer of enterprise applications, you'll probably find that most of these patterns are
familiar to you. I hope you won't be too disappointed (I did try to warn you in the Preface). Patterns aren't
original ideas; they're very much observations of what happens in the field. As a result, we pattern authors
don't say we "invented" a pattern but rather that we "discovered" one. Our role is to note the common solution,