Take breaks, meditate, think about other things, and give yourself plenty of time in both modes.
One way of making sure you’re taking regular breaks is to follow the Pomodoro technique. This is where you program for 25 minutes, then take a break for 5 minutes.
This is the idea of breaking what you want to learn into concepts. The goal is to learn each concept in a way that they each become like a well-known puzzle piece. In order to master a concept, you not only need to know it but also to know how it fits into the bigger picture.
After you finish reading this article (or any article), take a moment and try to state what you remember from the article. It’ll go a long away.
In order to avoid or break through illusions of competence, you should test yourself as you’re encountering new material. Recall is a simple example of this mini-testing.
The main takeaway on this point is not to spend too much time in one sitting going over the same material over and over again. The law of diminishing returns certainly applies. Spread it out over many sessions and over many different modes of learning.
Try to make a deliberate effort to teach what you learn to someone else