I've been programming for a little bit over a year, and have some experience in JavaScript, PHP, a tiny tiny amount of Java, and mostly C++. I've noticed that I've gotten to the point where I can program for, say, a couple of hours without checking to see if it runs, and then when I'm done for the night everything will build just fine. At least in the general case. That's very different from when I first started, and I'd have to click Buld and Run every 10 minutes just to make sure I'm not writing buggy code on top of already buggy code.
But now I'm starting to see that even though my code will build fine, there will almost always be some logical errors that, upon review, I say to myself "Why would I even write that? It's a simple mistake, but it makes no sense. I should've known from the start." I'd like to be able to change that about myself, and not make so many silly, illogical errors so that my first run of code on any project will be less buggy and weird.
Any suggestions on fun or interesting ways to change this? I've heard of Code Complete, but it's quite expensive. I thought maybe I should learn a bit more about actual computer science before diving into that book. I've never really enjoyed project euler. My mom loves doing things like cryptograms, but I never really had much fun with them. So other than stuff like that, what do you guys do that you think might improve your logical abilities?