We all develop habits. Some habits are good, some are very bad. Some are easily broken, others require extensive deprogramming. Our work habits are no different.
When I first started in the business I lived in Sillycone Valley and took jobs as a contractor at companies with Unix systems as a means to survive while attending classes. Most of these contracts entailed simple shell script maintenance. One of the things I learned, aside from a healthy loathing of the Unix administrators of the day, was that coding habits die hard.
Most of us in the IT world are familiar with the infamous “i”. The ubiquitous variable used in billions of lines of code all over the world to signify a simple numeric variable. Now, there is nothing intrinsically wrong with using “i” as a variable name, after all it can stand for integer, the type of value it represents. But what happens when you need more than one integer variable? Most just increment the alphabet and use the letter “j”, others just pick something, such as “x”. Again, there is nothing inherently wrong with this system as long as the scope is limited to such things as for loops and whatnot, then it is at least moderately decipherable.
But in those early days of shell and C programming that simple little “i” had quickly degenerated into the bubonic plague. This benign little vowel occurred dozens of times, in random places throughout every file. And it was joined by a random conglomeration of other vowels and consonants, each representing some value, be it a character or an integer. And of course there was my personal favorite, adding more “i’s” to create a new integer variable such as “ii” and “iii”.
And thus my own coding habits were set. Over the years I have learned to accept others for their coding habits, such as those above, but I cannot abide in them myself. Invariably this has led to what I call “Amateur Hour”. You see, that is what my code looks like and has been ridiculed as throughout my career. Everything is heavily commented to the point of redundant insanity, every variable is appropriately named and every line of code is spaced and aligned for readability. I don’t cram three lines of code into one just because it can be done (unless if makes better code, which it often does not). In fact, the most generic variable name I use is “iCounter” and only within the scope of a for loop.
In truth my code really does look like a ten year old has written it and I’m ok with that because while it may be publicly reviled and derided by more proficient developers, no one has ever complained that my code is difficult to read, follow or understand.
Will