If your goal is to make better use of your time, you need to identify why you can’t code for more then 2 hours.
There are days when I could be programming non-stop for a few hours before attending to important needs for myself. (like eating lunch haha) Then there are days when I could hardly stay focused for a few seconds and want to check my feeds or get distracted.
The reasoning for this is simple, its the level of stress being applied. In the first scenario I usually have things going easy, and things are flow and dramatic progress is being made, but its not difficult work. The second scenario I usually have things really rough and am working on a hard problem and my mind is just not in it.
I’m not saying that is your problem, but it could be, or it could be something else. Being able to identify the pain point will help you “fix it”. Its not as easy as me saying “suck it up and tie yourself down to learn for 8 straight hours!”. (don’t do that its not healthy)
It could be your getting easily distracted, or the work is too hard and you want to get distracted. It depends on the main reason why you can only sustain learning for 2 hours.
If your just getting yourself distracted because you are learning and learning can get stressful I recommend doing 1 thing, which is spend time reviewing what you already learned. The reason is 2 fold.
- You get to re-enforce what you should already know
- You get to take a “mind break” by just re-checking what you already learned, which should be less stressful and thus easier.
I personally learn by building things. I usually build something using around 80% of what I already know, while trying to integrate 20% of something I don’t know. That way I get to review what I should already know, and have myself a small framework of knowledge to try out new things. This way I can easily “connect the dots” between the new stuff and the older stuff I’m already more confident with.
This method wont work for everyone, as everyone has their own “method” of learning. I just recommend identifying what is the root cause, and see if you can change it to meet your goal.