Skip to content

Building Productive Habits Through Conditional “If-Then” Logic

“21 days is all it takes to form a new habit!”

Ever heard this old adage? Well, it turns out that it just might be… total bullshit.

But before we grab our debunking hammer and start swinging at every barrel of adages we see rolling toward us, let’s get down to the real business at hand.

Yes, I’m talking about habit formation.

We’ve talked about how beneficial it is to build strong habits before; essentially, doing so lets you use your limited amount of willpower on other things, ensuring you get more done on any given day.

What I didn’t talk much about before is how difficult it can be to build those habits.

Even if the whole “21-day” thing were true, that’s still three weeks you’d have to spend forcing yourself to do something before it became a habit.

Three weeks forcing yourself to get up at 6AM.

Three weeks forcing yourself to go to the gym every day.

Three weeks forcing yourself to write 1000 words a day.

Three weeks forcing yourself to jump off the roof of your apartment so you can become a professional stuntman someday. Thanks for the health insurance, dad!

Every habit you try to build requires an initial commitment of willpower that you weren’t having to spend before.

In addition, you’ve got to deal with all your other daily demands – both the regular ones that crowd your schedule and the unexpected ones that throw a wrench into everything.

So you might now be thinking:

“How can I make the process of habit-formation easier? Is there some super-secret technique that’ll help? Do I need to climb 10,000 steps to some temple in the far east and have monks teach it to me?”

Yes, there exists such a technique.

Luckily for you, I went and learned it from the monks myself. For the record, there were 10,114 steps.

Reaching the Top Step

…this I did, after an arduous 26-minute climb from the bottom. See, I usually take steps five at a time, but it was raining so hard that I had to go down to three. Safety first.

This was taken at step #10,078 – I swear.
This was taken at step #10,078 – I swear.

The monks welcomed me immediately as one of their own – and by “immediately”, I mean “immediately after sending me back down the steps for a case of water”.

Apparently they had no use for the rare blue flower I had brought them, and remembering the quizical looks they gave when I presented it reminds me that I now have a major bone to pick with Christopher Nolan.

Anyway, being the sensitive and culturally aware American I am, I decided to cut right to the chase and ask about the technique I’d come to learn.

“When do I get to meet Ra’s al Ghul?” I asked, directing my query to the nearest monk.

“You mean the Jao Aawaat, my friend”, the monk answered with a warm smile, right after delivering a swift kick to the abdomen for my insolence.

“Right after you clean up that blood you just rudely spit onto the floor,” he continued, “and complete six months of training.”

The light of several candles in a corner flickered across my face while I did the mental math. Six months…. that’s, like, half of a year! I certainly did not have time for that.

Luckily, that’s what montages are for.

15 minutes later, six months had passed. I now faced the head of the monastery and prepared to learn the ultimate technique of habit-building.

“The technique is inside you, my friend. You’ve known it all along.” he told me.

I thought for a moment.

“Oh yeah, you’re right.”

The Secret Technique

I had known the technique all along – and by that, I mean I actually used to use it all the time. And it’s very effective.

Somewhere along the way, I stopped practicing it. Eventually I ceased to think about, and during the past year my attempts at habit-formation have been based more around things like to-do lists. And self-loathing. All those days I was too lazy to jump off of my apartment roof….

However, I was recently reminded of the technique through a game I’ve been playing. That game is Magic: the Gathering, which I’ve discovered to be a superbly complex and rewarding game of strategy and customization.

Even if you’ve never played the game itself, I think I only have to give you one example to reveal the habit-building technique I’m talking about here:

Indrik Stomphowler

There it is, right on the card:

“When Indrik Stomphowler comes into play, destroy target artifact or enchantment.”

In MtG, this is called a triggered ability.

If you’ve ever done any basic programming, though, you’ll recognize this as a conditional statement.

Usually these are written in an “If-Then” format. Pretty much every programming language uses them, and they basically tell the computer:

“If Event X happens, then do Event Y.”

Here’s an example using actual code, in case you’re curious:

if (strlen($password)>25 || strlen($password)<6)
echo “Password must be between 6 and 25 characters.”;

This code basically says “If the user’s chosen password is more than 25 characters or less than 6, then display a message telling them the length requirement.”

Conditional logic is pretty simple, and you’ll find it everywhere if you look hard enough. In fact, conditionals are ingrained right into the behaviors of the most basic lifeforms:

If it’s trying to eat me, then GTFO.

And likewise, they’re found right at home in the high-functioning brains of modern humans:

If it’s trying to eat me, then give it a stern look, because it can probably be reasoned with. OH GOD WHERE DID MY LEGS GO

…alright, maybe the human brain doesn’t always make the most rational decisions.

But that’s exactly why conditional logic can be so powerful for habit-building. Before we get into the specifics, though, let’s learn a bit about how habits are actually formed:

Debunking the 21-Day Myth

The American Journal of Psychology defined habits like this:

“A habit, from the standpoint of psychology, is a more or less fixed way of thinking, willing, or feeling acquired through previous repetition of a mental experience.”

Habits are behaviors that are often performed subconsciously. New habits are difficult to form, but you can do it through repetition.

To be more clear, habits are formed through a process called context-dependent repetition.

Basically, when you frequently perform a specific action inside a given context – making a smoothie when you come home from school, for example – a mental link starts to form between that context (coming home) and the action (making the smoothie).

Eventually, the action is performed enough times within the context that a habit is formed.

Now, while we know that much to be true, the whole “You can form a new habit in just 21 days!” advice stands on shakier ground. In fact, researchers at University College London tracked down this commonly cited anecdote’s source, finding it to be a passage from a 1960 book called Psychocybernetics, written by Dr. Maxwell Maltz.

Dr. Maltz, who was a plastic surgeon before going into psychology, writes:

“It usually requires a minimum of about 21 days to effect any perceptible change in a mental image. Following plastic surgery it takes about 21 days for the average patient to get used to his new face.”

One way or another, this finding on the results of plastic surgery was applied to habit formation, and the anecdote spread wildly.

UCL researchers decided to test this advice by doing a rigorous study of habit formation. What they found through their research was that the average time it took a participant to form a new habit was actually 66 days – quite a bit more than the oft-cited 21.

In addition, they found that there was a lot of variation in how strong habits became for each test subject; less complex habits like drinking water peaked in habit formation strength sooner than more complex habits like doing 50 sit-ups.

The UCL researchers reported all this and more in a fantastic article, which I highly recommend reading if you’re interested.

In summary: You’re going to have to do a lot of repetition before a specific behavior becomes a new habit. The more complex or difficult the behavior is, the harder it’ll be to form. And it probably ain’t gonna be a breezy 21-day process.

Using Conditional Logic to Build Habits

Alright, so now that we know the basics of habit formation – and why it’s often so difficult – let’s look at how conditional logic can lend a hand in the habit-building process.

The idea here is to use the trigger – the “if” portion of the conditional statement – to remind yourself to practice the habit (the “then” portion).

Applying this to the context-dependent repetition ideal, we’re basically building contexts that work well as triggers.

To make this work, you need to ensure that your trigger is something you already do every day.

In order to make myself drink more water, I chose a trigger that I already do all the time – going to the bathroom. Each time I went to the bathroom, I’d immediately fill my water bottle back up and drink the whole thing.

To make myself do more pull-ups, I put a pull-up bar in my door frame so that walking into my room could become the trigger. Each time I walked into my room, I’d stop and do five pull-ups.


Notice that you’ll sometimes have to do some legwork to make your trigger suit the habit you’re trying to build. Without the pull-up bar being in my door frame, walking into my room isn’t a very good trigger to do pull-ups. The means to practice the habit need to be built right into your trigger.

Let’s take an example that’s given me more trouble than usual: getting up early in the morning.

I love to be up early; on any given day, I’d rather get my start at 6 AM rather than 10 AM.

However, actually getting out of bed is… well… really freaking hard. Sleepy Thomas does not have the same values as Normal Thomas.

Now, if I have a reason to get out of bed early – a meeting or a prior commitment to someone – then I can easily get up early. This is why I’ll often volunteer to pick my friend up from his night shift at 6:30 AM.

Without a good reason, though, getting up is hard. So it’s time to break out the conditional logic.

Initially, I tried building the same trigger that everyone uses.

If my alarm goes off, then I will get up.

Yeeeaaahhh… nice try. In practice, the snooze button is hit 30 times. So I tried building a stronger trigger by placing my alarm far away from my loft bed:

If my alarm goes off, then I will get out of bed and go turn it off.

At this point, the trigger seems pretty strong. If I don’t get out of bed, it’s going to continue to squak at me.

Well, it turns out that my sleepy self will go to extreme lengths to keep sleeping – including getting out of bed, hitting snooze, and climbing back up. Again and again.

Alright, let’s try something else. Rewrite the trigger:

If my alarm goes off, then I will do 20 push-ups and turn it off.

In addition, I make one small tweak to the trigger. I put my alarm clock under the small table in my room.

Since I have climb out of bed and then get on my hands and knees to reach the clock anyway, doing the push-ups is easy enough. And after doing them, the exercise has woken me up enough to not hit snooze. Success!

While we’re on the subject, my other method for waking up early – which has a 100% success rate – is setting up a system that will punish me if I don’t get up on time.

The important part I’m trying to illustrate here is that you might need to get imaginitive when creating your triggers.

Hop to It, Soldier!


Sometimes I wish I had a drill instructor around to make me practice all the habits I want to build. Maybe you feel the same – after all, we’re both probably familiar with what freedom can do to our productivity.

For most things, though, we simply don’t have anyone telling us what to do. That’s why techniques like this one are so useful; they help us lessen the burden on our willpower reserves.

However, this technique won’t help you if you don’t use it. 

So, now that you’ve read the article, it’s time to start building some habits! Take a few minutes and think of a habit you want to form. In what context would you perform that action?

Once you know the context, think about how you can turn it into a trigger that’ll automatically remind you to perform the task. I’ve given you a few examples in this article; now it’s time to you to get creative.

Want even more help building good habits? Check out our guide to the 10 best habit tracking apps.

photo: drill instructor