Consistency and discipline over motivation
One of the beautiful things about being a developer is that many of us actually have the opportunity to take an activity we enjoy, and make it our job. Many developers are happy to do some extra work or learn something when they're at home or in the weekend just because they are so eager to learn and play. While this is pretty awesome, it won't last forever. You won't be motivated to learn every single day. Especially once you start doing development as a full-time job. I experience this as well, sometimes I have a couple of days or even weeks where my motivation is through the roof. I'll get tons of work done and the days just fly by. On other days I just can't seem to get started, everything is distracting and the motivation just doesn't seem to be there. When I look at some of the more senior developers I know, it seems that they have moved past this phase. They always seem to be motivated and sometimes they just seem extra motivated. They just seem to have no shortage of the good stuff! How do they do this?
Is it motivation you should look for?
If you think about it, motivation isn't worth much. It's just not there all the time and you can't build a solid career based on it. When I was looking for ways to improve motivation I came across posts like this, telling me that I should get disciplined. Some went even further and said that motivation just isn't worth your time.
Because of these posts I started to realize that motivation is a great driver of productivity. But only when it's there. When motivation isn't there, every job seems like a chore. Have to adjust a form on a website? It sounds terrible when you're not motivated. You'd have to create a new input field, maybe change a database table and more. You get tired just by thinking about it. But then consider doing that same thing when you're motivated. You probably would get excited because you get to possibly improve the product and code base that you're working on. This isn't feasible in the long run though, when you want a job in development you'll need to train yourself to become more consistent, more disciplined. Motivation will be the bonus, not the requirement.
Changing motivation into discipline
If you want to be more disciplined you'll sometimes have to be pretty tough on yourself. There's rarely a valid excuse to not do what you're supposed to do. So instead of postponing things until you feel motivated or obliged to do them, just get started. If you do this, and are consistent about it, you'll see that it helps. I often find that it helps to not jump in headfirst like you would when you're super motivated but to just sit back first. Take 15-20 minutes to figure out what it is that you're going to build, what code are you going to write. Figure out what sub tasks there are and split them up in blocks that will take about 40 minutes to complete. If you do this, you will have a great structured overview of what you're going to do. You'll know how busy you are for the day or week and you'll be able to plan accordingly. During those 40 minute work cycles try to turn off notifications that might distract you. Discipline yourself to only check notifications in between your 40 minute cycles.
After a 40 minute cycle it's time to take a quick break. And try to make it an actual break, get up and grab a drink. If there's email or anything similar that requires your attention, take a peek. Reply if needed or add replying to your to-do list. Make it a part of a 40 minute cycle if the email requires you to figure something out in-depth. Otherwise, use the break or extend the break a little (but not too much, 10 minutes should be the maximum). In the beginning you might feel like you're restricting yourself because everything has to be thought about or planned in, you can't just start doing something and then do something else until you're out of motivation. That's fine, you are training yourself to have a consistent and disciplined workflow. If you find that 40 minutes is too long or too short for you you can always change the cycles. You could even do that on a day-to-day basis if you feel like it's appropriate for the tasks you're working on. I personally found after a few weeks that I prefer 50 minute cycles with 10-15 minute breaks.
The benefits are real
When I look at more senior developers I notice that many of them have a workflow similar to this. They take multiple short breaks throughout the day and between those breaks they tend to be very focused on the tasks they have to complete. They don't have their Slack open all the time and they work on a single thing at a time. And they are consistent about that. Everyday they seem to be able to flick the switch and go into work mode. Of course they still have more and less motivated days, but a motivated day will just make them super productive instead of only productive because being productive is their default setting.
So let's get out there and become consistently more disciplined!