How to Access Patterns
Patterns document knowledge that many developers and projects share. If you know a fair amount of them, you will be able to find better solutions quicker.
To support such a strong claim, take a look at the contents of patterns. While many authors have their individual style and preference, these elements will be there in some form or other:
- a name
- a problem to be solved
- a solution
- some argueing about the appropriateness of the solution
- some analysis of the applied solution
The strength of a pattern is not just the solution. It also provides insights on why this is a good solution. And it gives you information not only on the benefits, but also on possible liabilities. So when you start some discussion in your team about how to solve a problem at hand, you have all the arguments with you. A pattern allows you and your peers to make well informed decisions. It can make all the difference between "this is how it is done" (a stale attitude that prevents new ideas and change) and "this is how it is done here" (an attitude that is aware of a world outside of the acquired habits and open to evaluation and learning).
Now that patterns are ultimately useful, the hard part is to enable yourself to use them. Hard problems will come up all of a sudden, and your peers will not wait for someone to claim "I'll find a pattern for this, give me a week to search." You need to have pattern knowledge before you actively consider using one. This is the hard part: not only does it require lots of work in advance (and patterns often are not the most enjoyable pieces of literature), it also violates how humans learn - when applying some solution, or at least linking the stuff we read to some experience already present in our brain.
This is why I suggest a three-pass reading style for patterns.
- the name and the first sentence of the solution;
- the problem, the solution and the consequences;
- everything including implementation aspects and examples.
The first pass I do with every pattern I come across, and this is quite a few. It takes seconds, and you get an impression of what this pattern is all about. Your impression may be mislead, but that is ok for now. When some discussion pops up in your project, you will remember such a pattern and you'll be ready for the second pass. Isn't it a bit late by then? Not necessarily: before some problem needs to be solved urgently, most projects have some warning time. If you are aware of what is going on around your desk and task, you will be ahead just a bit - and this is sufficient.
The second pass is meant to give you all the ammunition you need in the heat of a design discussion. You will be able to judge proposals, and to propose some pattern yourself - or not to propose it. This will bring the team forward. Take some care of the pattern name in this phase. Depending on the team culture, the name may not ring a bell, and it is better then to just explain the idea of the solution.
The third pass is in order when you have decided on some pattern and you need to implement it. If you are a bit like me, you wouldn't stand to read 30+ pages of some pattern before you are certain to implement it. Pass one includes a paragraph at most and involves a minute. Pass two requires to understand about 2 pages of printed paper and can hardly be done in less than 15 minutes. Pass three requires hours, but his is productive work time then.
There is a whole bunch of knowledge available how to write your own pattern and how patterns can be used to capture parts of the knowledge of your team and company. But this is a different story and shall be written another time.