There's a couple things I've been trying to focus on when I work on code. I feel like it's yeilding good results.
1) Make Your Intentions Clear
If your intentions are clear, you get two good things out of that. First, the person maintaining your code will be able to understand it quickly. Second, that person will be able to understand what the code was supposed to do, not just what it is doing. Obviously, if the maintainer is able to quickly understand your code - both what it says, and what it does - she saves time, and code strong like ox.
2) Minimize Your Variables
If you have to track 20 variables in your head while you're thinking about some piece of code, you're probably going to screw it up. Ok, you're a super smart programmer dude, but still, it's going to be much easier for you to handle one or two variables than 20, no matter how ripped your memory muscles are.
How Do You Do It?
Sure these are nice ideas, maybe, but how do you go about implementing them? Well, here's some ideas.
Use names that highlight the important concepts. If you think about your names that way, it's pretty easy to come up with names that are very clear and concise. Take into consideration what is in scope and what's nearby. If it's obvious that you're working in the List class, maybe the name "settings" is good enough. And if you're using settings but it's not immediately clear that they're list settings, "listSettings" is a good name. Poetry - a few words say so much.
Extract methods - factor-out the algorithms. Do you have a 20-line chunk of code with a comment at the top saying what it's doing? Move it into it's own method, and use that comment as the name. This is a standard refactoring straight out of the Refactoring Book - it is goodness. This reduces your cognitive load when you're reading the code, and it minimizes the variables that are in scope. Now you won't need five cans of Coke to get the job done - you'll drink them anyway, but you'll be able to get more work done!
Keep an Open Mind
See the state of things. See the possibilities. React appropriately. Sometimes you'll be able to code like this, and sometimes you'll have to leave things be and move on.
Happy Coding!

