I find it easier to let patterns emerge when I am
programming, than actually build them in from the get go.
You can see patterns emerge if you
- make objects to introduce points of variation, so that supplying a different object changes the behavior of the client
- make smaller objects that make up another when it becomes too big
- pass an object around when some method requires too many parameters
- you find two similar ways to do something, so following OnceAndOnlyOnce you make objects to capture the similarity
- the oldie but goodie, make objects so that data and functions remain together.
It seems that most patterns arise out of these manipulations. Or maybe
it seems like that, now that I already know the patterns.
In some cases, I have seen developers put in too many classes in the
name of following patterns. I got a couple of them into the
habit of discovering the need for patterns instead of anticipating it.
-- AamodSane
See also: ExtremeProgrammingAndPatterns, CanAnArchitectureEmerge