Coding has been a hot topic over the last few years. A lot of people want to start programming and become a developer. So how can you develop a coding habit?

A few days ago, I started to read The Power Of Habit by Charles Duhigg. This book made me think a lot about why some people struggle with programming daily. I think it's because of the habit process. Most people don't know how habits work and need concrete examples.

In this article, I'm going to explain what a habit is and give you some advice to help you create a daily programming habit.

What is a habit?

Before starting, it's essential to define what a habit is and how you form one.

If we check the definition of the word "habit" on Google, we find this:

"Habits are routines of behavior that are repeated regularly and tend to occur subconsciously" ― Wikipedia
"a behavior pattern acquired by frequent repetition or physiologic exposure that shows itself in regularity or increased facility of performance" ― Meriam-Webster Dictionary
"a recurrent, often unconscious pattern of behavior that is acquired through frequent repetition" ― The Free Dictionary
"something that you do often or regularly, often without thinking about it" ― MacMillan Dictionary

As you can see, a habit is an automatic process in your life. Take brushing your teeth, for example.

It's interesting to define the components of a habit to understand how it works.

Each habit includes three components: a cue, a routine, and a reward.

The Habit Loop

What is the cue?

The cue is an event in your life that triggers a habit. Every time you do something automatically, it was started by a cue.

Most of the time, a cue is defined by time, an emotional state, a location, or an action.

For example, if I'm working and suddenly smell coffee from my colleague's direction, my habit "Taking a coffee break" is triggered.

What is the routine?

The routine is what you are doing while the habit process is running. You can define whatever you want it to be in this part. As I said previously, it can be, "I'm going to take a coffee break."

What is the reward?

The reward is the final element of the process. In other words, what this routine has done for you. For the coffee break example, the reward is "Thanks to the caffeine, I feel less tired, and I am more dynamic."

The more positive and pleasant the reward is for yourself, the more your brain will save the habit.

"This process within our brains is a three-step loop. First, there is a cue, a trigger that tells your brain to go into automatic mode and which habit to use. Then there is the routine, which can be physical or mental or emotional. Finally, there is a reward, which helps your brain figure out if this particular loop is worth remembering for the future. Over time, this loop—cue, routine, reward; cue, routine, reward—becomes more and more automatic. The cue and reward become intertwined until a powerful sense of anticipation and craving emerges. Eventually, whether in a chilly MIT laboratory or your driveway, a habit is born." ― Charles Duhigg, The Power of Habit: Why We Do What We Do in Life and Business

A little exercise

Here's something you can do: take one of your daily habits and try to define the cue, the routine, and the reward. Once you do, you're ready to read the next part on how to create your daily programming habit.

How to make programming a daily habit

All you have to do to make programming a daily activity is to create a routine.

You are free to define what you want for each part of this exercise, but I will give you a few tips to help you.

For the cue, you can try to define something based on time:

  • Every morning right after I wake up
  • When I come back from my job
  • During my lunch break
  • [Insert a time-based cue]

Routine will be our most straightforward element to define. You can just say, "I want to code for 30 minutes," "I'm going to learn [Insert a skill] for 30 minutes," or many more.

Finally, one of the most critical parts will be the reward. As I recommended in the first part of my first productivity article, you need to establish goals for yourself. It's going to help you define a reward. Every time you practice your habit, you are closer to your goal.

Try to determine a long term goal, and inside of that, a lot of small goals.

For example, you can say:

  • I'm getting closer to my goals for the week.
  • I'm getting a little closer to my final goal.
  • If I code right after waking up, I'll make myself breakfast as a reward.
  • [Insert a reward]

A challenge that can help you

One of the best ways to get into a habit is to follow a 100DaysOfX challenge. This challenge is designed to help you create a pattern and commit to it every day by sharing what you did on Twitter, Instagram, or your blog.

The reason I'm telling you about this challenge is that it became famous on Twitter with the 100DaysOfCode.

I strongly recommend that you read the rules on the site and get started. You'll see, at first, it may seem big and impossible, but you'll find it fun to do.

Besides, you will most certainly get support on Twitter, which will motivate you.

"Are you passionate about self-improvement? Eager to change your habits, have tried to do so many times, but had difficulties changing them? Life always seems to get in the way, there is not enough support, and you feel like you're alone in it? Find yourself thinking, "What's the use of all this self-improvement if I always seem to go back to where I started from?" ― 100DaysOfX

If I recommend this challenge to you, it's because I'm doing it. I'm thrilled with the results, and I'm only starting.

For my part, I'm doing the 100DaysOfReading challenge. I always wanted to start reading but I never took the time to do it. Thanks to this challenge, I'm on day 17, and already finished one and a half books.

My habit loop:

  • Every day before lunch or before sleeping (the cue).
  • I read 20 pages or more (the routine).
  • I am approaching my long-term goal of reading daily. I am close to my short-term goal of finishing the book. It makes me happy because I have always wanted to read daily (the reward).
  • I publish a quote from the book I'm reading with some explanations and motivational text on my Twitter (the commitment).

Here are some tips that can help you to create your programming habit.

Plan your tasks

To work every day and achieve my monthly goals, I plan all my tasks the evening before. I put on paper what I want to make, and every time I do it, I'll scratch it off my list. I recommend that you do this with your daily programming habit because it's going to motivate you and satisfy you a lot when you finish all your goals.

If you need more structure in your work, define what you are going to do, how, when, and why.

For example, I'm going to create a landing page for my website (what I'm going to do). I will use Vue.JS to build it (how). I will do it between 8am and 10am (when). It's going to help me better understand Vue.JS and help me to start getting my visitor's email addresses.

Code your dream project

What could be better than coding daily while working on the project of your dreams? If you need motivation, it's an excellent way to program every day. Don't be afraid to take the initiative. Doing it a little bit every day will motivate you even more and give you results in a short time.

Find the field you want to work in

The world of programming is vast – web, software, AI, embedded, and much more.

One of the significant difficulties is to define what you want to do as a programmer.

It's not easy for everyone, but choosing a topic and sticking to it can be a good motivation factor to practice daily.

For example, if you choose web programming, just focus on that. Even though it's still a big topic, you removed software, AI, embedded, and everything else. That's a good start.

To go further, you can choose between the front-end and back-end.

I'm telling you all this because often, when you start, you get demotivated fast because there are too many things, and you can't focus on a specific theme.

A good environment

Something that can motivate you in your daily programming habit is a pleasant working environment. I do not recommend working in your bed. You're going get tired easily.

Try to work at a desk or a table and do whatever you need to feel comfortable in that space. It will make you want to work more efficiently.

Further reading

If you are interested to know more about the habit process, I invite you to read The Power of Habit by Charles Duhigg. This book helped me a lot while writing this article, and a lot of the examples I gave you were inspired by it.

I've also heard about Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones by James Clear. This book offers a framework to improve your daily habits. The author tries to provide practical guidance on how to make changes.


Do you plan to make programming a daily habit? Are you going to commit to 100DaysOfCode?

Feel free to share this article if you liked it.

If you want more content like this, you can follow me on Twitter, where I tweet about web development, self-improvement, and my journey as a full stack developer!