Staying focused while learning to code

While I have been learning to code I've found that there is one thing that has slowed down my progress. It's learning to focus on what I'm studying. Usually about half way through my study time I find myself completely distracted and not able to complete simple problems. Here are a few things that I have learned to do to help keep this problem from reoccurring.

Have a plan. This is one of the things that I struggled with early on. The first half of my study time was spent trying to figure out what on earth to start with. My advice is to plan your next study/coding session AFTER you've just completed studying. This has worked for me because my head is already in the game. At the end of studying just jot down the things that you would like to get done during your next session. That way you'll know exactly where to start next time. Rinse and repeat.

Set aside time alone. This may be difficult for some people as most of us have busy lives. It is super important to have a set time (the same time preferably) every day where you are by yourself in a quiet environment that allows you to focus. I've found that (for me) early in the morning before everyone is awake and it's nice and quiet works quite well. Even if you can only manage to set aside an hour or so you will see the difference that this alone time will make.

Be ready. Before you begin your studying ensure that you have everything that you need. Computer, notepad, coffee, etc. This will keep you from having to get up and break the focus that you've worked so hard to plan around. Also, give yourself a few minutes to get focused. It usually takes me about 5-10 minutes of setting up to really get in the zone. Plan for this in the time that you set aside.

Practice. Whenever you are doing something slightly mundane (driving, taking a walk, etc.) try practicing focus by choosing a problem that you would like to solve or understand throughout the day. For example, I like to look at the CodeWars website and see the challenge of the day. I print it out and carry it in my pocket (I do the same thing with the exercises from Eloquent Javascript). Every once in a while I will look at it and try to work it out in my head. Sometimes I will find that I am completely unable to focus, but forcing myself to focus again is good practice.

I hope that these tips that have helped me can help you as well. If we can get better at focusing, we'll be able to learn faster, understand more, and make our self-taught journey more efficient.