How to have a productive programming day

by Jason Swett,

Why productivity is desirable

The way I look at productivity is this: if I have to be at work all day, I might as well get as much done in that chunk of time as I can.

It’s not about running myself ragged. It’s not about “hustling”. It’s simply about not being wasteful with my time.

In fact, my goal is to accomplish more than average developers do, but with less time and effort.

Why bother being productive? Because the more work I’m able to get done, the faster I’ll be able to learn, the smarter I’ll get, the better my job will be, the better my career will be, the more money I’ll earn, and so on. And if I can achieve all that at the same time as reducing effort, then it’s an obvious win.

Here are some high-level productivity tips I’ve learned over the years.

Start your day early

The most helpful productivity tip I’ve learned in life sounds dumb but it actually works: get up early and go to bed early. Ben Franklin was right about that one.

I’m not sure why this tactic works. One hypothesis I have is that if you start your day earlier than other people, then you’re starting your day before other people start interrupting you.

In any case, I don’t care why it works, I just care that it works.

Start real work right away

The first hour of the day has been called the rudder of the day. I’ve found that if my first hour is a productive one, then the rest of the day will be productive also, all the way through. Conversely, if my first hour is lazy and unfocused, the entire rest of the day will be lazy and unfocused as well.

Don’t start your day by checking email, reading news, scrolling Twitter, or anything like that. These activities can cause a state that Mihaly Csikszentmihalyi calls “psychic entropy”. In other words, those activities scramble your brain.

Instead, start doing real work, immediately when you sit down at your computer. It sets a good tone for the day.

Start with something highly tractable

The more ambiguous or open-ended a task is, the harder it will be to get straight to work on that task, and the harder it will be to get that first hour of solid productivity under your belt. So don’t start with a task like that. Start with a task that’s sharply defined.

This is actually not necessarily very easy. In order to have a sharply defined task, someone (possibly you) has to have done some work in advance. In the best case, you have a fine-grained to-do list laid out, which originated from a small and crisp user story, which is part of a clearly-defined project.

We’ll talk more in a moment about how you can ensure that you always have highly tractable work to start your day with. First, a few more “meta” tips.

When possible, exercise before work

On the days when I exercise before work, I often feel sharper and more alert than when I don’t. I don’t drink coffee on a daily basis anymore, but when I used to, I would feel less of a need for coffee in the morning on the days when I exercised beforehand.

Since I hate wasting time, I don’t like to go to the gym, which seems like a really time-inefficient way to exercise. Instead I like to ride my bike to the office. I also have some dumbbells in my office so I can lift weights throughout the day. Obviously, you can do whatever type of exercise works for you.

Don’t eat too much

Eating too much can be an energy-killer. I’ve found that eating too much can make me tired, lazy, and just put me in a worse mood. And of course, eating too much habitually can make you fat. That’s obviously bad.

I used to go out to eat with co-workers for lunch almost every day. Then, around 2pm, the greasy tacos or burger and fries I ate for lunch would catch up to me and I would get so sleepy that I would want to die.

Later in life I started packing a lunch instead of going out to eat. Restaurants always give you too much food. Homemade food is usually not as bad for you as restaurant food. I didn’t feel as bad after a packed lunch as I used to from restaurant food, although I would still get tired a lot, especially if my lunch happened to be leftovers from a heavy dinner like meatloaf. I typically felt pretty good after lunch if I ate a salad instead.

Here’s what I do today. You might think this is crazy, but it actually works out really well for me. I just don’t eat anything until dinnertime. In other words, I skip both breakfast and lunch. I’ve found that I don’t get nearly as hungry as I would expect. Ironically, I find myself much less distracted by hunger throughout the day than I used to when I used to eat lunch. I also feel much more alert than when I used to eat food during the day. Plus, as you might expect, I’ve lost some weight as an added bonus.

Don’t drink too much caffeine

With caffeine, the productivity highs are higher but the lows are lower, at least for me. I personally seem to be especially susceptible to the lows of caffeine. When I switched from coffee to tea (black tea which still contains caffeine, much less than coffee), I noticed that I slept better and felt better during the day. As a result of the fact that I’m not jacked up half the time and lethargic half the time, I feel like I’m smarter on average than when I used to ride the caffeine rollercoaster.

In my experience, the biggest drawback of caffeine is that it negatively affects my sleep.

When possible, keep email, Slack, Twitter, etc. closed

Distractions and interruptions are obviously bad for productivity. Keep these things closed when you can. Despite how obvious this advice sounds, my perception is that a lot of people don’t follow it.

Keep your browser tabs to a minimum

Each browser tab you have open has costs. First, a browser tab costs attention. When you have a tab open, you’re assigning a little bit of “mental RAM” to that tab. That’s a little bit of precious mental RAM that can’t be used for something else, something more useful.

A browser tab often also costs time. I wish I had a dollar for every time I was sitting with a student or co-worker and they click through their various tabs, trying to find the tab they’re interested in. So wasteful.

Instead of keeping a bunch of browser tabs open on the off chance that you’ll need to get back to their contents at some point, just close them. The net cost of re-finding any content you need later is way less than the net cost of always keeping a bunch of browser tabs open.

Work on one thing at a time

The fastest way to get a bunch of things done is to work on one thing at a time.

When you pause task A in order to work on task B, you’re giving yourself an opportunity to forget the details of task A. Then, when you resume task A, you have to refamiliarize yourself with the details of that task. That’s a waste. You could have just loaded those details into your head once instead of twice.

Of course, it’s not always possible to keep on a task until it’s all the way done. Sometimes you have to pause to wait for feedback or for a long-running command, for example.

In these situations I’ve found a way to mitigate the context-switching costs. If I have to switch to a different task, then instead of switching to a different programming task, I’ll work on something that’s entirely different in nature. For example, if I expect to have to wait just a few minutes or up to an hour, I might use that time to read a programming book or work on a blog post. If the task I switch to is totally different, it doesn’t compete for headspace the way a similar task would.

If for some reason I have to set down a task for a few hours or more, then I usually just suck it up and switch to a different programming task. But that’s a last resort, not a Plan A. And the need to switch tasks can be minimized by using good development practices like small, crisp user stories that are shovel-ready by the time developers start to work on them.

Practice automated testing

The productivity benefits of automated testing are numerous. I’ll list some of them.

First and most obvious, writing automated tests saves you from having to do as much manual testing. Now that I know about testing, I dread the idea of coding a feature the old way, where I have to perform a series of manual testing actions after each change I make.

Second, testing forces you to articulate and justify every piece of code you add. testing makes it harder to violate YAGNI. YAGNI violations are pure waste.

Third, testing often helps you to think of all the use cases you need to exercise for your feature. When writing tests, it actually becomes fun to try to exhaustively list all the scenarios under which your feature could possibly fail.

Fourth, the test suite that results from testing helps protect against regressions. Regressions cost time.

Lastly, testing has a tendency to improve the understandability of code. The reason is that code that’s easy to test often takes the form of small and loosely-coupled classes and methods. It also just so happens that small and loosely-coupled classes and methods are easier to understand than large and interwoven classes and methods.

Try hard to write code that’s easy to understand

As Bob Martin has said, “the only way to go fast is to go well”. After all, the reason we call good code “good code” is because good code is faster and less expensive to work with than bad code.

Remember not to fall into the fallacy that you can gain speed by cutting corners. Every extra hour that you spend doing worthwhile refactoring (key word “worthwhile”) saves three hours of future confusion.

Always know what you’re working on

One fairly guaranteed way to not accomplish much is to not even know what you’re trying to accomplish.

The best way of keeping track of what you’re working on is to write down what you’re trying to achieve. This can be a written statement in an automated test (another benefit of testing) or just a note in a note-taking program or even a note on a piece of paper.

The more specific your objective is, the easier it will be to accomplish. Half the difficulty in doing any piece of work is determining exactly what needs to be done.

Keep a to-do list

Mental RAM is a previous resource. It’s wasteful to use up your mental RAM by trying to remember all the things you have to do. Instead, write those things down.

This is another practice that sounds simple and obvious but is often not followed.

End the day with a plan for tomorrow

The ideal morning is one where you can sit down and immediately begin working. If you have to begin your day by making a difficult decision—the decision of what to work on among the infinite possibilities in front of you—then your morning is probably going to go worse, and your day will probably go worse as a result.

So, each day, try to make at least a vague note for the next day to remind yourself what you want to work on tomorrow. If you don’t want to box yourself in, remind yourself that you can always change your mind.

End the day with a deliberate loose end

I used to prefer to stop working when I reached a good “stopping point”. These days I deliberately avoid stopping at a good stopping point.

Instead, I leave a loose end that I can pick up on the next day. One tactic I like to use is to write a failing test so that my obvious first task for the next morning is to get that test to pass.

Takeaways

  • If you have to be at work all day, might as well get as much done as possible.
  • Get up early and go to bed early. For some reason it helps you accomplish more, even if you work the same amount of time.
  • When you sit down in the morning, start real work right away. Don’t start with email, news or social media.
  • Start with a piece of work that’s tractable rather than something ambiguous. This will help you gain momentum faster.
  • When possible, exercise before work. It will probably increase your cognitive capabilities for the day.
  • Don’t eat too much during the day. Especially avoid “heavy” foods. Eating too much can kill your mood, energy and cognitive abilities.
  • Don’t drink too much caffeine. Caffeine provides a “local high” but in my experience the drawbacks of too much caffeine, including especially the negative impact on sleep, make high caffeine intake not worth it.
  • Keep email, Slack, Twitter, etc. closed.
  • Keep your browser tabs to a minimum. They’re not worth what they cost.
  • The fastest way to get a bunch of things done is to work on one thing at a time.
  • Practice test-driven development. TDD helps protect from regressions, helps improve the understandability of your code, and helps keep you focused.
  • Try to write code that’s easy to understand. It’s faster to work with easy-to-understand code than hard-to-understand code. Even though it can take more time and effort to write clean code than messy code, the net effect is a great time savings.
  • Always know what you’re working on. You’re unlikely to accomplish much when you don’t even know what you’re trying to accomplish.
  • Keep a to-do list rather than trying to hold all your to-dos in your head, wasting precious “mental RAM”.
  • End the day with a plan for tomorrow so that you don’t have to spend the first part of tomorrow figuring out what you’re going to do.
  • End the day with a deliberate loose end so that it’s easy to hit the ground running the next day.

11 thoughts on “How to have a productive programming day

  1. Julius

    Great article. Thank you very much this was indeed helpful and I have seen some faults i have and i am ready to correct them and grow to become a more productive developer

    Reply
  2. Charlesweb

    It’s a great article, but I would also point out that you have to get up once an hour if you want to have back health problems for life. I also point out that I don’t want to be the best, but I try to be good at what I do, and of course I want to live, not just be in front of the PC, so many hours on a PC you end up burned out….

    Reply
  3. B

    “accomplish more than other developers do, but with less time and effort.”

    This sounds very competitive and not healthy at all.
    It’s important to achieve as much as you can without having to compare yourself with others. People’s pace and sense of achievement changes a lot, you don’t need to try to be better than others, you can simply try to be the best version of yourself.

    Reply
  4. DeGrowth Forward

    Stop comparing yourself with others. The hyper-growth is destroying the planet as a result of people such as yourself.

    Reply
  5. Peter Panski

    I feel this is so American and so wrong. There is no intrinsic meaning or value in “being productive”. I am getting paid for my time. I do not get more money if I plan properly an being more productive.

    – Starting erly gives me headaches. I am actually more productive if I sleep till wake up by myself. Do not use an alarm clock is my take away

    – Exercise before work I am tired and can’t concentrate. If I execise after work I am sleeping way better.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *