Bit of a blogpost here because I'm looking at a section of code I wrote months ago, and trying to figure out what kind of bewildering fey mood I was in when writing this maddening grimoire of computer text.
Log your crap down, guys. Keep a notebook handy beside your computer and jot down some basic logic. Comment liberally and then worry about cleaning those up post-release versions, and that's after you've kept an original with all the documentation.
Best of all, reading back your own logic and explaining it helps you realize when you're being a complete dolt. Right now I'm going through some logic responsible for spawning items randomly selected from a preset level-dependent pool, called from an object that itself is similarly randomly selected, and instead of just using a Resource initializer like a good little Unity scrub, wanted to get fancy by trying to index everything with a few pointers and some overcomplicated reflection. I literally have a cork board right next to me with pins, notecards, and red string to keep track of this one bit of functionality in my game, like I'm plotting all the goddamn connections between the Illuminati and Illumination Entertainment. And I'm probably just going to rewrite that entire bit too because it's completely asinine, but I can't do that until I figure out what the clean-burning Hell I'm doing in the first place.
Don't be like me. Write your crap down.