2010-05-11

On whitespace and other coding "monstrocities"...!

Why exactly is it that programmers all seem to be anal retentive?

Some of the best coders that I have been witness to have been extremely reflexitively irritated by certain things that do not fit their view of 'good coding practices'. Most recently, I was reading archives of coding horror when I came across this post, which can be pretty much summed up as 'OMG WTF dem white spaze not l33T nuff!' While I definitely respect Jeff's work (okay, most of it anyways!), and feel that he's spot on most of the time (really!), I wish that people would stop propogating the misconception that you have to be anal retentive to be a good programmer.

Having worked in mid-to-large sized teams for most of my development career, I can safely say that everyone will run up against different coding practices, and different ways that people believe things should be done. Take this for example:

public String doStuff() {
    return "Because I said so!";
}

Can become..

public String doStuff()
{
    return "Because I said so!";
}

Or..

private String EVERYONE_LOVES_CONSTANTS = "Because I said so!";

public String doStuff() {
    return EVERYONE_LOVES_CONSTANTS;
}

...and there are plenty of other permutations!...

At most shops there is someone that sets standards, and usually gets pretty upset if they aren't followed. Really, it doesn't matter! Honest! They're all usable. All can be self-documenting. Conventions are helpful, but that's all they are. Conventions. If you can't read code you haven't programmed (particularly with use of a decent code auto-formatter), then you have bigger problems to solve! All I have to say is this: If you want my code to have extra CR/LFs, I darn well better have a huge monitor to deal with a heck of a lot of whitespace on my screen at a time.

Yes, most good programmer are pretty OCD about a lot of things. Going 'over the edge' about little things like that only leads down the path of madness, especially if you wander through many different shops in the corporate world.

No comments:

Post a Comment