Hooray! Another tie-in with Scott Hanselman's recent post. That's two in two weeks. At this rate, I won't have to come up with any original content, just feed off someone else's. I follow the same philosophy in my coding so it's nice to have some spillover to other parts of my life.
ANYway, Scott's post is on Mindful Coding. The idea is that programmers need to guard against spacing out while coding, something that also hits close to home because spacing out is probably my family's raison d'etre. My brother can do it so completely that the gum he's chewing will actually fall out of his mouth. So, ya, it's something I try to be...ummm...mindful of.
The tie-in is with my half-developed notion of Conscientious Coding. The idea that you should be coding with a mind that someone else will be looking at, debugging, and maintaining your code someday. Maybe not today or tomorrow but at some point, your code will be subject to critical review. And not by a code reviewer whose goal is to make sure standards are followed, but by someone who actually has to understand at a very intimate level what your code does. Including yourself a year from now after you've forgotten what it is the code originally did.
Until now, I've focussed mostly on the aesthetics of how code looks for Conscientious Coding. Judicious use of white space, adding comments for gestalt (and information, if you're into that sort of thing). I still think this is an overlooked aspect of software development but it's getting better thanks to Visual Studio's ability to export IDE settings.
The idea also extends to how you're coding as well, though. I've read my share of code whereby I would take great pains to avoid meeting the author for fear that my polite Canadian sensibilities would fail me.
This is more than your typical enterprise-level code written by a junior developer. That I can deal with. That's code by people who just don't know better. Many of them recognize that. What I'm referring to is DailyWTF (sorry, guys, the new name isn't as catchy) code by people who not only don't know better, they think they do. People who will look back at code they wrote six months out of college and say, "Now THAT is some fine logic." (Which leads to another personal motto: You can't save everybody.)
The underlying concept of Conscientious Coding (and I really need to stop capitalizing it because it makes it seem I've put some thought into the mantra) is to be nice to the person who has to read the code a year from now, especially because it might be you. Learn to recognize when something doesn't smell right even if you can't do anything about it right now (either from lack of time or lack of knowledge or both). Don't get complacent six months into the project and start taking shortcuts. Recognize problems that someone has probably already solved somewhere else. Read up on new techniques that might fit your problem.
And try not to space out too much.