Stop Coding From Stealing Your Dreams

We’ve all been there. It’s late at night. You’re in bed. Everything is perfectly fine. You don’t have any worries at all. In fact, everything is so good that your brain decides to find a problem.

You remember some of the logic trivia puzzles that have troubled you during LeetCode sessions. Your developer mind torments you as you try to find a solution, even in twilight hours.

The Developer Life

Developers like to think of themselves as problem solvers. Some developers work as night owls enjoying working through the night solving problems and delivering value.

But sometimes, just sometimes we can’t switch off. There might be no real reason for this like in the case of a string of parentheses not forming a palindrome. It’s not good for you, it’s bad for your health and it’s not even good for clarity in coding.

The Palindrome Solution

I hope none of us are asked this question in an interview. 

The String “()()” is not a palindrome but “())(“ is.

Can be confusing (particularly late at night). Here is what is going on, by using substitution to make our reasoning clear.

A string is considered a palindrome if it reads the same backwards and forwards. 

At first glance it looks like the string “()()” should be a palindrome but let us investigate this. If we swap “(“ for “A” and “)” for “B” — and we can do that since both are simple screens — our string looks like “ABAB”

I think we can all agree that “ABAB” is not a palindrome, as reversed it is “BABA”.

Likewise, “())(“ is a palindrome. Again we swap “(“ for “A” and “)” for “B”. Our string is now “ABBA”.

“ABBA” is a palindrome as reversed it is “ABBA”.

Either the substitution helps here, or just reversing the string should make this easier to understand.

What Is Going On?

You’d think that after a day of PRs, CI/CD pipelines, merge conflicts and more your brain would be happy to have some vacay time. 

Nope. You’re constantly background processing. This is fine when you have a short-term problem which requires focus to solve, or you need a burst of energy at the end of a sprint.

The lack of a clear boundary between home and work, exacerbated by the work from home setup many of us have adopted has meant that coding problems can even work their way into our sleep. Spending your days jumping between issues (and screens) doesn’t help us to switch off and can lead to burnout.

Programmers tend to be a detail-oriented bunch, and this makes us good at what we do. It drives us to constantly learn and continually improve. Unfortunately, it also keeps us awake at night, thinking about parenthesis when we should be counting sleep.

What Can We Do?

Next time you find yourself staring at the ceiling at 3 AM, try these techniques to switch off during your next working day. It might just save you from burning out and help preserve your problem-solving capabilities for problems that require (and deserve) full focus.

Make Like a Mirror and Reflect

Spend a few minutes at the end of your workday to reflect on what happened during your workday. Write down your unsolved problems and set a time during the next workday to solve them.

Exercise

Physical activity can tire your body out, making it easier to fall asleep. Take a walk outside, get a grip on your mind. Even moderate exercise can make a big difference in sleep quality.

Limit Caffeine and Sugar

You are what you consume. Caffeine and sugar intake are damaging, particularly in the late afternoon and evening. Find healthy alternatives and use them.

Disconnect at Night

Avoid screens for at least an hour before bed. Don’t bother to go “anti-blue-light”, just avoid all screens just before sleep. If you’re going to read, don’t read a book about coding just before bed.

Use a Bedtime Routine

If you want to move into sleep mode, use your body’s routine to help. Prepare for sleep from about 7 PM, thinking about what will relax you including activities, what you eat and drink and what you think about. This can pay dividends through repetition and routine.

Conclusion

Don’t dream about coding. Code by day, sleep by night and develop a routine to become the best software engineer you can be.

It’s better to think about how to treat your mind and body now rather than how to deal with burnout. Think about that, then act on it as I have suggested.

Previous
Previous

5 Debugging Confessions

Next
Next

Why Companies Should Run Tech Tests on Existing Software Engineers