HabitsBreaking Bad Habits Series
IntroductionWe 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 disciplineSome people will seem to have more willpower Really they have just developed good habits
4
Gaining HabitsThis can take time and will be different for
everyoneThere 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 TriggersIdentify the Cue
Let's consider writing a testWhat 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 RewardThink about the reward you get from writing tests
6
Breaking HabitsVery difficult!
Easier if you can control your environment so that you can avoid your cue
Even with the right motivation it is toughPerhaps gaining new stronger habits is easier
8
CravingsThere is one more important aspect to gaining
habitsAfter Identifying Cue and RewardsNeed 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 HabitsUnfortunately 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 HabitsCharles Duhigg proposes a framework:
1.Identify the routine2.Experiment with the rewards3.Isolate the cue4.Have a plan
13
Coding HabitsMost of us will write code a certain way out of
habitOften the way we learnt ‘how’ to codeThis can span from naming conventions to more
advanced principles and practices (i.e. SRP)
Can you identify any habits you have formed?
14
Clean CodeElegant, 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 CodeSo how can Habits help us write Clean Code?
Or improve other aspects of our day to day work?
16
RecapFocus 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
ReadingThe 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