Habits
Breaking Bad Habits Series
Introduction
We all fall into habits
Becomes easier to do something a certain way the
more we do it
Can you identify your bad and good habits?
2
“We are what we repeatedly do. Excellence,
then, is not an act, but a habit.”
- Aristotle
By sticking to good habits and identifying our
bad habits - we can become better developers
3
Habits
So...uhmm...how?
By identifying the triggers of bad habits
Identifying a bad habit is pretty easy!
Identifying the triggers is trickier
We are not born with discipline
Some people will seem to have more willpower
Really they have just developed good habits
4
Gaining Habits
This can take time and will be different for
everyone
There is no immediate fix for gaining habits
“...ranged from 18 to 254 days; indicating considerable
variation in how long it takes people to reach their…”
Lally, P. et al. (2010). How are habits formed: Modelling habit formation in the real world. European Journal of
Social Psychology. 40 (6), p998-1009. http://onlinelibrary.wiley.com/doi/10.1002/ejsp.674/abstract
5
Identifying Triggers
Identify the Cue
Let's consider writing a test
What time is it? Who are you working with? Time?
How are you feeling? What are you working on?
What does the code look like in front of you?
Identify the Reward
Think about the reward you get from writing tests
6
The Habit Loop
7http://charlesduhigg.com/how-habits-work/
Breaking Habits
Very difficult!
Easier if you can control your environment so that you
can avoid your cue
Even with the right motivation it is tough
Perhaps gaining new stronger habits is easier
8
Cravings
There is one more important aspect to gaining
habits
After Identifying Cue and Rewards
Need to start craving the reward
If we can do this then it will become a habit
9
The Habit Loop
10http://charlesduhigg.com/how-habits-work/
Forming New Habits
11http://charlesduhigg.com/how-habits-work/
Forming New Habits
Unfortunately there isn’t a magic formula
Habit change is different for each individual and for
each habit
Each person is also driven by different
cravings
12
Forming New Habits
Charles Duhigg proposes a framework:
1.Identify the routine
2.Experiment with the rewards
3.Isolate the cue
4.Have a plan
13
Coding Habits
Most of us will write code a certain way out of
habit
Often the way we learnt ‘how’ to code
This can span from naming conventions to more
advanced principles and practices (i.e. SRP)
Can you identify any habits you have formed?
14
Clean Code
Elegant, Efficient, Maintainable, Structured
Causes of ‘dirty’ code:-
Time Pressure, Lack of Training, Motivation
We should always strive to write Clean Code
15
Habits and Clean Code
So how can Habits help us write Clean Code?
Or improve other aspects of our day to day work?
16
Recap
Focus on good habits
Remembering to think back to today on how we can
form these into good habits
Identifying Habits - Both good and bad!
Working on good habits
17
Reading
The Power of Habit: Why We Do What We Do, and How to Change
Charles Duhigg (2013)
Short web version: http://charlesduhigg.com/how-habits-work/
How long does it take to form a habit?
UCL News (http://www.ucl.ac.uk/news/news-articles/0908/09080401)
18

Habits

  • 1.
  • 2.
    Introduction We all fallinto habits Becomes easier to do something a certain way the more we do it Can you identify your bad and good habits? 2
  • 3.
    “We are whatwe repeatedly do. Excellence, then, is not an act, but a habit.” - Aristotle By sticking to good habits and identifying our bad habits - we can become better developers 3 Habits
  • 4.
    So...uhmm...how? By identifying thetriggers of bad habits Identifying a bad habit is pretty easy! Identifying the triggers is trickier We are not born with discipline Some people will seem to have more willpower Really they have just developed good habits 4
  • 5.
    Gaining Habits This cantake time and will be different for everyone There is no immediate fix for gaining habits “...ranged from 18 to 254 days; indicating considerable variation in how long it takes people to reach their…” Lally, P. et al. (2010). How are habits formed: Modelling habit formation in the real world. European Journal of Social Psychology. 40 (6), p998-1009. http://onlinelibrary.wiley.com/doi/10.1002/ejsp.674/abstract 5
  • 6.
    Identifying Triggers Identify theCue Let's consider writing a test What time is it? Who are you working with? Time? How are you feeling? What are you working on? What does the code look like in front of you? Identify the Reward Think about the reward you get from writing tests 6
  • 7.
  • 8.
    Breaking Habits Very difficult! Easierif you can control your environment so that you can avoid your cue Even with the right motivation it is tough Perhaps gaining new stronger habits is easier 8
  • 9.
    Cravings There is onemore important aspect to gaining habits After Identifying Cue and Rewards Need to start craving the reward If we can do this then it will become a habit 9
  • 10.
  • 11.
  • 12.
    Forming New Habits Unfortunatelythere isn’t a magic formula Habit change is different for each individual and for each habit Each person is also driven by different cravings 12
  • 13.
    Forming New Habits CharlesDuhigg proposes a framework: 1.Identify the routine 2.Experiment with the rewards 3.Isolate the cue 4.Have a plan 13
  • 14.
    Coding Habits Most ofus will write code a certain way out of habit Often the way we learnt ‘how’ to code This can span from naming conventions to more advanced principles and practices (i.e. SRP) Can you identify any habits you have formed? 14
  • 15.
    Clean Code Elegant, Efficient,Maintainable, Structured Causes of ‘dirty’ code:- Time Pressure, Lack of Training, Motivation We should always strive to write Clean Code 15
  • 16.
    Habits and CleanCode So how can Habits help us write Clean Code? Or improve other aspects of our day to day work? 16
  • 17.
    Recap Focus on goodhabits Remembering to think back to today on how we can form these into good habits Identifying Habits - Both good and bad! Working on good habits 17
  • 18.
    Reading The Power ofHabit: Why We Do What We Do, and How to Change Charles Duhigg (2013) Short web version: http://charlesduhigg.com/how-habits-work/ How long does it take to form a habit? UCL News (http://www.ucl.ac.uk/news/news-articles/0908/09080401) 18

Editor's Notes

  • #3 As a horse pulls a cart, tracks will start to form. At first the tracks will be shallow and the cart and still veer off course but the more we do it the same way then the tracks become deeper and the cart becomes easier to pull in the same direction. Then it becomes hard to change direction.