This is the eleventh article from the series "Tips from The Clean Coder". Here we gathered and summarized the main tips from the eleventh chapter.
Imagine that you're having an out-of-body experience, observing yourself on an operating table while a surgeon performs open-heart surgery on you. That surgeon is trying to save your life, but time is limited so he is operating under a deadline - a literal deadline.
How do you want that doctor to behave? Do you want him to appear calm and collected? Do you want him issuing clear and precise orders to his support staff? Do you want him following his training and adhering to his disciplines?
Or do you want him sweating and swearing? Do you want him blaming management for unrealistic expectations and continuously complaining about the time? Do you want him behaving like a professional or like a typical developer?
The professional developer is calm and decisive under pressure. As the pressure grows he adheres to his training and disciplines, knowing that they are the best way to meet the deadlines and commitments that are pressing on him.
The best way to stay calm under pressure is to avoid the situations that cause pressure. That avoidance may not eliminate the pressure completely, but it can go a long way towards minimizing and shortening the high-pressure periods.
We must make sure that risk is quantified and presented to the business so that they can manage it appropriately. Accepting unrealistic commitments thwarts this goal and does a disservice to both the business and to ourselves.
Professionals will always help the business find a way to achieve their goals. But professionals do not necessarily accept commitments made for them by the business.
This is easy to say. But when your business is failing, and your paycheck is delayed because of missed commitments, it's hard not to feel the pressure. But if you have behaved professionally, at least you can hold your head high as you hunt for a new job.
We can avoid pressure by keeping our system, our code, and our design as clean as possible. This does not mean that we spend endless hours polishing code. It simply means that we don't tolerate messes. Professionals realize that "quick and dirty" is an oxymoron. Dirty always means slow!
You know what you believe by observing yourself in a crisis.
If you follow the discipline of TDD in non-crisis time but abandon it during a crisis, then you don't really trust that TDD is helpful. If you keep your code clean during normal times but make messes in a crisis, then you don't really believe that messes slow you down.
Choose disciplines that you feel comfortable following in a crisis. Then follow them all the time. Following these disciplines is the best way to avoid getting into a crisis.
Forestalling, mitigating, and eliminating pressure is all well and good, but sometimes the pressure comes despite all your best intentions and preventions.
Manage your stress. Sleepless nights won't help you get done any faster. Sitting and fretting won't help either. Rushing will only drive you deeper into the hole.
Instead, slow down. Plot a course to the best possible outcome, and then drive towards that outcome at a reasonable and steady pace.
Let your team and your superiors know that you are in trouble. Ask them for their input and guidance. Avoid creating surprises. Nothing makes people angrier and less rational than surprises. Surprises multiply the pressure by ten.
Pair! When the heat is on, find an associate who is willing to pair program with you. You'll get done faster, with fewer defects. Your partner will spot things that you miss, will have helpful ideas, and will pick up the slack when you lose focus.
By the same token, when you see someone else who's under pressure, offer to pair with them.
The trick to handling pressure is to avoid it when you can, and weather it when you can't. You avoid it by managing commitments, following your disciplines, and keeping clean. You weather it by staying calm, communicating, following your disciplines, and getting help.