The Pressure of Deadlines
In these next two chapters of The Clean Coder, Uncle Bob provides tips and techniques to meet deadlines while staying cool under pressure. Often times we set deadlines as commitments, and unfortunately not all commitments are carried out on time. This failure in keeping your promise is the source of nearly all distrust in any relationship, whether it be professional or personal. So how do we effectively come up with a deadline for our projects? Since problems can arise at any time, they can throw off deadlines to extend far longer than originally projected. To meet target dates, we really need to think of them more as estimates.
Businesses like to view estimates as commitments. Developers like to view estimates as guesses.
Professionals don't make commitments because they know there is always some level of uncertainty with every task. Because businesses need deadlines in order to plan ahead, they rely on the developers to commit to a target date. Professionals draw a clear distinction between estimates and commitments, and will only accept commitments when they are absolutely certain that the task can be carried out. Typically, this is not the case, and the professional will instead provide a trivariate analysis - an estimate of three numbers:
Optimistic Estimate - A wildly optimistic estimate, of less than 1% chance of occurrence, which can only be achieved if absolutely everything goes right.
Nominal Estimate - An estimate with the greatest chance of success.
Pessimistic Estimate - A wildly pessimistic estimate, also of less than 1% chance of occurrence, which takes everything that could possibly go wrong into consideration.
Given this set of estimates, we can find the expected duration of the task to be as follows:
The standard deviation of the expected duration of the task is described below:
This number is the measure of the amount of uncertainty a task entails. Using probability distribution to determine a realistic estimate is a good way of factoring in any unexpected issues that may arise during the task as this number considers both best-case and worse-case scenarios. Professionals are very careful to set reasonable estimates despite the pressure to try to go fast.
Uncle Bob introduces several techniques to incorporate your team in determining realistic estimates.
Flying Fingers - A technique that's been mentioned in a previous post. Team members sit around a table and tasks are discussed. For each task, the team is asked for optimistic, nominal, and pessimistic estimates by raising their fingers based on how long they believe the task will take. If everyone agrees, then they go onto the next task. If there disagreement, then they continue discussion until an agreement is reached. Simultaneity of revealing fingers is very important in this technique as peoples' minds can be swayed based on what they see other people do.
Planning Poker - Systematically equivalent to flying fingers, except team members are given a hand of cards with different number on them. Members choose a card that matches their estimates, and sets the card faced down on the table. When everyone has decided, the cards are simultaneously revealed.
Affinity Estimation - All tasks are written onto cards, without any estimates showing. Team stands around a table with cards spread out randomly, and members sort the cards relative to one another. Tasks that take longer are moved to the right, and smaller tasks are moved to the left. This method is done in silence, and any member can move any card at any time. If any card is moved more than n times, the card is set aside for discussion. Eventually discussion of the order of the tasks begin, and lines between the cards are drawn to present bucket sizes. Traditionally, five buckets are drawn in a Fibonacci sequence.
While these techniques aren't the only methods to determining estimates, they are methods that have been proven to be effective in creating practical estimates.
Estimates are not error-free and when facing a large task, it is often beneficial to break the task into several smaller tasks to minimize error. An implication of the Law of Large Numbers suggests the following:
If you break up a large task into many smaller tasks and estimate them independently, the sum of the estimates of the small tasks will be more accurate than a single estimate of the larger task.
While doing this still won't guarantee an error-free estimate, it is good practice to break the tasks up to better understand the task as a whole and to uncover any surprises that may arise.
The business will always want commitments because they want to eliminate risk. We are honor bound to help the business find a way to meet commitments. However, we are not honor bound to accept the commitments.
So how do you avoid pressure? Business may be down your neck about having this and that done and you're stressing out. The best way to stay calm under pressure is to avoid the situations that cause pressure. Unrealistic commitments thwarts the goal of eliminating risk, so accepting them just does a disservice to both the business and you.
You may be tempted to rush and drift away from your disciplines and beliefs to meet deadlines. Don't! In doing so, you'll only cause messes that will only create more pressure down the road. You can avoid presure by keeping your system, code, and design as clean as possible by sticking to your disciplines at all time.
You can't always avoid pressure though, and it's important to handle pressure appropriately. When faced with pressure, don't panic. Manage your stress, think the problem through, and work at a reasonable and steady pace. Rushing will only drive you deeper into a hole. Communicate with your team to let them know that you're in trouble. In doing so, you can receive help from others and they won't be greeted with any surprises.
The only way through the pressure cooker is to rely on what you already know works - your disciplines.
Again, trust your disciplines. There is never a time to question or abandon them, and they are there to guide you through times of high pressure. Finally, get help! Pair with your peers to help you think of helpful ideas, point out any mistakes, and help you keep focused to drill through your program.
Creating and meeting deadlines can cause a lot of pressure and stress. Professionals remain calm and collected when the going gets tough, and it's how you deal with this pressure that sets you apart from nonprofessionals.