Improve Your Sleep (as a Developer) 💤
Tags: sleep, productivity, health, watercooler
Published: 2020-03-19 13:53:46

In this post, I won't go into details why sleep is important because there is a lot of information about it already. What I would like to do instead is to share my personal experience of improving my sleep quality and schedule.

I was never a great sleeper: it usually takes time for me to fall asleep, and my sleep schedule goes all over the place if I don't work on it. When I have started working remotely with a flexible schedule several years ago, it became even worse. I would get up and fall asleep later and later each day, it would take longer to fall asleep and I felt like I had less time during the day. I tried different things then but wasn't very successful. I didn't end up sleeping through the day and working through the night but I still got up late, and my schedule wasn't consistent.
The situation changed a lot later when I had my daughter. Then I had to get up earlier but it meant even less sleep! And I don't function well on little sleep (I think that most people are like this, but some of us won't admit it)

There is plenty of advice online and in the books on the topic, but I found out it's often hard to follow, and sometimes it's not applicable "as is", so I had to adjust.

I will go through the things that I tried and share if it worked for me or not.

## Have a Sleep Schedule

Almost every sleep-related article will tell you to maintain a set schedule even for the weekends. While that could be useful in general, I found out that I feel better if I let myself sleep in when I can, especially if I was sleeping less than needed several days before. One or two days of sleeping in won't ruin my schedule if I follow the other rules.

For me, the total amount of sleep I get during the week is more important than having a rigid schedule, especially if some kind of "emergencies" happen, and I end up sleeping less one of the nights.

I also don't understand how people manage to improve their schedule by just going to bed earlier. I would never be able to fall asleep like this. For me, the first step to "fix" the schedule is always to get up earlier, be a bit sleep-deprived, and then be able to fall asleep earlier.

However, when I already have a more or less consistent schedule, going to bed at the same time works well. I struggle with following this advice strictly, because on some days I may be less tired and sleepy, and I would get bored by going to bed and trying to fall asleep. I'll describe what helps me with this issue in the next section:

## Limit Screen Usage Before Sleep

Popular advice is to avoid using devices several hours before sleep. While that could be useful, it's not always possible or easy to do.
I also found out that for me most problems are caused not by the blue light. The bigger problem is when I browse the internet right before sleep. In this case, I'm likely to be distracted from being sleepy by worrying too much (like these days), or I'll get new ideas and become too excited about them.

So what I do is: avoid devices after 11 pm, except for my e-book. It seems easy, but it was already hard enough to make this habit stick. First, I started with 11:10 and then moved the time a little earlier. I also use [a simple habit tracker](https://play.google.com/store/apps/details?id=org.isoron.uhabits) to watch the progress. This way I read for 10-15 minutes and feel sleepy, even if the book is interesting. Exceptions are outstanding fiction books that can still ruin my schedule :D

## Limit Caffeine

This one turned out to be crucial for me. I used to drink several cups of coffee a day without realizing that I was caffeine-sensitive. I used to think that I was just a bad sleeper, that's why I wasn't able to fall asleep quickly 🙈

Later, I experimented a bit and found out what amount of caffeinated drinks I can consume harmlessly. Now I have a small coffee at a coffee shop several times a week, but no later than 12 am or 1 pm. An additional benefit from this is that getting a more quality coffee feels like a treat and cheers me up on days when I get up early.
I can also drink a can of Coca-Cola occasionally, especially if I feel sleepy. It has less caffeine than coffee but works better for me in terms of energy. But Cola is addictive for me, so I make sure to limit it as well. Tea contains caffeine too, but it has less impact on me, so I just make sure not to drink strong tea in the evening.

## Be Active During the Day

I don't have time and energy for a full workout every day, but even doing a small one (5-20 minutes) makes a difference.

Another important thing is spending time outside, especially in daylight hours. I make sure to take a break in the middle of my working day and take a walk. Sometimes it's hard to get away from the computer, but I try to do it anyway. Such breaks are helpful in several ways: they give our eyes and brain some rest, provide light exposure, and keep us active. All of these improve our sleep.

## Keep a Sleep Diary

That's especially useful when figuring out an optimal schedule and the amount of sleep you need.
Initially, I used paper log and electronic tables to track my sleep, but now it's enough to check sleep records in my fitness bracelet app (though it tends to lie and I need to edit the entries)

These were actions to take when attempting to a set sleep schedule in the long term, but

## What to do when you can't fall asleep right now?

### Do Mental Exercises

Count sheep? That could be boring, and often isn't effective. At some point, I used counting backward or performing arithmetic operations in my head. This works better because, this way, our brain is occupied but not fully engaged in this activity, so it helps to get in the sleepy state.

Another exercise is recalling what happened during the day step by step. This is suitable for kids too, I used this method with my daughter.
A similar thing is planning the next day, but if you are like me, try not to get too excited or worried about it.

### Get Up if you're Unable to Sleep for 30 Minutes (or so)

I don't fully understand this advice. Am I supposed to look at the clock from time to time? In general, I avoid it not to worry about the amount of sleep that is left. And even if I'm not able to fall asleep, I'm usually tired and prefer to lie and have rest even if I'm not sleeping. Sometimes I pick up a book and read for 15 minutes or so before attempting to fall asleep again.

However, I think that it's still good advice and works in some cases, like when you're too stressed and uncomfortable. Getting up, doing something else for a brief amount of time, and then going back to bed prevents our brain from getting stuck trying to fall asleep. But I keep this one for exceptional situations.

There are a lot of other things to try, like:

- keeping your bedroom dark, cool, and silent
- using a sleeping mask and earplugs
- wearing wet socks
- using a weighted blanket
- taking melatonin
- having a ritual before sleep
- breathing techniques

But I either haven't tried them or thought that describing them from my perspective would be too boring to include in this post.

What about you? Do you use any techniques to make your sleep better?

I would also be grateful for book recommendations on the topic. I've read [Peter Spork's book](https://www.goodreads.com/book/show/17415443/) and found it useful. It contains both scientific information behind sleep and practical advice. Unfortunately, this book is not available in English, but you can read it in German or Russian.