I did not write this, I took it from a comment on Reddit.
Make yourself do it every day (with occasional days off; sometimes you have to let your brain chemistry balance itself out), have several projects to switch between when you get burned out, and don't program when you should be sleeping.
That's the easy stuff. Here's the real secret:
You know that feeling when your brain hurts because something is "too hard to implement" and/or there's "too much drudgery" to get through? Overcoming that is probably the most important part of becoming a strong programmer.
Many martial arts involve a kind of conditioning which basically involves getting the crap kicked out of you, generally known as "iron body". This is partially for pain tolerance, but the name "iron body" is apt, because it also causes small chips and fractures in the bones, which heal to make the bones stronger and denser.
It is a simple fact with programming that at one point or another, most problems worth solving will hurt your head to think about. It may be the expanse of implementation details you can imagine stretching to the horizon, the abstractness of the problem, the difficulty of wrapping your mind around a particular equation, etc.
You have a choice: reject this idea, and waste a lot of time trying to find the perfect project which will be all fun all the time. You will become frustrated as you give up on every project you start. Or you can accept this simple fact and train yourself to have "iron mind":
- Tolerate a little mind pain and work through it. It will be unpleasant, but you should get over it pretty quickly. You can do fun/easy parts too, but try to get an hour or two of unpleasantness in every day.
GOTO 1.
Two main things will happen. The first is that you will learn to deal with mental strain so that it doesn't bother you so much. The second is that you will learn how to divide up and fit problems into your mind so that they don't hurt to think about. The latter part is, I think, really key, because it is not merely a coping mechanism, but a problem solving skill. As time goes on, the definition of "unpleasant" will change; so long as you keep making yourself work through whatever "unpleasant" means, you will keep growing.
At least, this is how it has been for me.
Also: caffeine. Oh, and water. Caffeine without enough water will just make you feel shitty. If you drink tea, you're guaranteed to get enough water. Stay away from caffeine pills.