Human beings are creatures of habit. There is no denying that we developers fall victim to those habits. It wouldn’t be so bad if the majority of developers had good or healthy habits, however, this is generally not the case. There is the compulsion to grab that can of soda, a handful of M&M’s, or light up that cigarette outside. For the most part, these habits are committed to muscle memory, which is why most of us don’t notice the act itself. To become a healthier individual you have to understand how habits work and in doing so, you will see how to change them.
Understanding the Habit Loop
A habit consists of three primary parts:
- the cue
- the routine
- the reward
For example, every afternoon you are at your desk and want to get a cupcake. You get up, walk to the break room, grab an office supplied cupcake, and devour it. It is not hard to see that this isn’t exactly a healthy habit. Looking at this from a high level, the cue was hunger, the routine was walking to the breakroom, and the reward is the cupcake.
How to Bring About Change
There is no exact formula to changing a habit so be prepared to put in some time and effort. What I have found useful is a framework described in Charles Duhigg’s book The Power of Habit: Why We Do What We Do in Life and Business. He mentions 4 steps: Identify the routine, Experiment with rewards, Isolate the routine, and Have a plan
Identify the routine
Given the example above, the routine would be you get up, walk to the break room, and eat a cupcake while chatting with a fellow coworker.
Experiment with rewards
And here comes the less obvious part: why did you get the cupcake to begin with? Was it hunger? Boredom? The need to take a break from the coding you are working on?
In order to find out what craving is driving a habit, you need to experiment. This should come as second nature to developers, as we love to experiment with coding, whether the results are good, bad, or hilarious. This experimentation may take hours, weeks, or even longer, so don’t get discouraged. The next time you feel the urge to get a cupcake, instead get a cookie. The following day try it again but this time with an apple (or healthy snack). Next, try socializing with a coworker and leave the food out of the equation all together.
Hopefully, you see the pattern here. Each time you get back to your desk, jot down the first three things that come to mind. Then set a timer for 15 minutes. When the timer is up after socializing with a coworker, do you still feel urge to get cupcake? If so, social interaction might not be what is driving your behavior and in fact you are actually hungry. If it is hunger, then you have identified your reward.
(Side note: the rise of obesity in the United States has lead to individuals not only being overweight but also malnourished.)
Isolate the cue
Now that we know the reward we can isolate the cue. In this endeavor our good friend science comes to the rescue. Experimentation has shown that cues fall into five categories:
- Emotional state
- Other people
- Immediately preceding action
Once you get back to your desk answer these five questions:
- Where are you?
- What time is it?
- What’s your emotional state?
- Who else is around?
- What action preceded the urge?
Much like experimenting with rewards, this may take a few days or longer. Answering these questions will help draw a picture of what is triggering an urge. In the example above, it is hunger.
Have a plan
When a routine, a cue, and a reward are identified you can begin to change (better) a routine by planning for the cue and choosing the behavior that returns the reward. You can think of a plan like a switch statement:
You may not keep to the plan always, but when you keep trying these changes will eventually become your new habit.