i am a stickler for coding conventions. part of making code readable is to adhere to some set of standard coding conventions. i’ve been using the same set of conventions for a long time now, which means that at least when i look at my own code it looks properly formatted. what pisses me off is when i have to deal with code that has tabs all over the place inconsistently. it’s ugly, it’s awful, and it pisses me off.
i’m working with code where the code is a mess. there are no regular conventions used, it almost looks like people used whitespace on a whim. it’s like writing english sentences and using punctuation whenever you feel like it. now, i know that i never capitalize when i write emails or blog entries, and i’m sure that there are those of you out there where it’s a big pet peeve and it grates on you. fine, i get that. sorry. but at least the meaning of the content is clear. at least, you know, in my head it all makes sense. but i just spent 10 minutes looking at a block of code trying to figure out why something isn’t working when it should be and i finally found out why. it’s because the previous programmer decided that the use of braces and whitespace isn’t very important to them.
in some places code looks like:
if ($variable==true) {
// do this
// and do this
} else {
// do that
}
in other places code looks like:
if ($variable==true) // do this
and in other places it looks like:
if ($variable==true) {
// do this
} else // do that
and in other places it looks like:
if ($variable==true) { // do this } else { // do this; //do that; //do this too; }
it kills me. i’m glad that i enforced a coding convention when we had multiple programmers here. all of our new code looks beautiful.