Mental breaks are essential to successful programming. To me this doesn’t just mean taking a break from work and then returning 15 minutes later. It means switching topics and activities, having multiple varied tasks planned into your day, and giving yourself time to think about an idea. It means switching between creating, learning, play, and rest.
Part of the learning and creating process is being able to completely change the focus of your mind and then come back to that thing later. When you are with your friends and family don’t be obsessing over the problem that you couldn’t solve! Let it go, and come back to it fresh, this will allow you to be rested and have new ideas. It may seem like you are ignoring your work and it therefore reduces your productivity but because you cannot function at your best without these habits of mental health the result is exactly the opposite and you will be more productive and especially produce much higher quality work.
I would even go so far as to throw some meditation in there, but that’s just me.
When looking for coding resources online while researching a problem, before trying to read and understand the ideas trying to be conveyed do an initial smell test to see if it is even worth your time. Is it written well, easy to understand, logical, and clearly formatted with examples? Does it contain simple and elegant solutions that are not unnecessarily complicated? If you don’t do this you will end up in situations where you feel you are inadequate because you can’t understand what you are reading or the solution seems to not work or be more complicated than it really is.
Patience is central to learning, there are two main parts. The first is not to be frustrated at how quickly a solution comes to you. Just sit with the material, and gently keep your focus on it, the understanding and solutions will naturally come. The second is to not be thinking about the next thing you have to do or feel distracted, pressured or hurried, rather to feel comfortable focusing on what is in front of you. if you feel impatience or are mentally distracted it will greatly reduce you learning and problem solving abilities.
It is very common and useful to get sidetracked in programming. While solving a problem you start to research one thing which leads you to research another and so on. This is a useful thing to do, but not if you get lost in it. Make sure not to stray too far away from your original goal, and come back to it often, you will not make meaningful progress if you don’t accumulate time focused on completing a specific project
When learning programming in general or while trying to solve a specific problem try to avoid jumping from site to site in google searches. This is a very fragmented disorienting way to receive information. The best thing to do is stick to a few highly recommended books and the official websites of the technology you are working with. If you want to learn about MySQL for example visit mysql.com. There are other very useful sites such as stackoverflow.com, which should only be used as a supplement to a core study of either a good book or an official website.
Reading programming knowledge is one thing, but in order to grasp the principle in a usable way it is necessary to recreate the information you took in. This can be as simple as taking notes or as complex as creating an example, the more complex the better. Making the effort to remember and actualize whatever principle was understood while taking the information in is a vital part of learning.