Refactor a Habit by Changing its Input
2 min read

Refactor a Habit by Changing its Input

If a habit were a function, what are the ways you can refactor it? One way is to adjust the input parameters by removing them or changing their values.
Refactor a Habit by Changing its Input

Habits are sort of like functions in programming. Consider this habit I had for the longest time:

function SnoozeAlarm(wantToGetUp) {
    if (wantToGetUp) {
        return 'Wake up';
    } else {
    	return 'Sleep';
    }
}

This function takes some input about whether I want to get up and produces some outcome (a "reward", Sleep or response, Wake up).

I usually don't want to get up. I want to stay snuggly warm in my bed and snooze the alarm until I have to get up. Before COVID and working at home, catching the bus to get to work on time forced wantToGetUp to be true during the week.

But not long into COVID, I found myself back at not wanting to get up. I honestly wanted to wake up on time, I just couldn't bring myself to want it enough when I was awoken by the alarm.

One tactic for refactoring a habit is to adjust its input. Was there a way I could ensure wantToGetUp is true in more cases than not during the week? My kids are my alarm on the weekend, I don't need to set one 👶.

So what did I change?

I changed my nighttime routine to charge my phone on our bathroom counter instead of on my bedside table where I could reach it easily.

This way, the alarm is going off far enough away where I need to get up and turn it off. I'm now in the whiz palace, which is the first stop after getting up anyway.

I also enabled the alarm's Google Assistant routine which immediately starts telling me what my calendar events are and what the weather is like. It will even resume playing my podcast episode.

So effectively this forced wantToGetUp to be true all the time:

function SnoozeAlarm(true) {
    if (true) {
        return 'Wake up';
    } else {
    	return 'Sleep';
    }
}

And we know as good programmers that we can remove the else condition. Now the refactored habit looks more like this:

function WakeUpOnAlarm() {
    return 'Wake up';
}

If you think about it, the function could be refactored to simply return true all the time now, which means I likely don't need it. Goodbye habit 👋.


Enjoying these posts? Subscribe for more