Neither my father nor I are particularly meticulous people in the rest of our lives, but you could eat off his hubcabs or my team's code. I think it's critical that new developers are taught this principle from the beginning, and are mentored through their early impatience.
My father is a self-taught auto mechanic, and passed on a lot of 'fixing things' philosophy while I held a flashlight for him in our driveway as a child. Often I would grow cold and impatient and decide we would never succeed in our task. He would say: "There are two kinds of people in this world- the people who can fix the car and the people who can't. The person who never gives up eventually fixes the car. The person who gives up before it's fixed will never fix anything." When people fail to fix something it's not because they took the wrong steps in attempting to start fixing it, it's that they give up before they're done. Some of them even give up before they start, and others may give up right before they would have succeeded. He also felt it was important for the car to know which kind of person you are, to intimidate it into submission. Really it's just important that you know which kind of person you are, to believe in your ultimate victory as a protection against frustration. This philosophy is what gave me my reputation of being undefeatable by bugs- I simply refuse to give up fixing them as a matter of principle. (I also like to curse at them at times threateningly so they know who they're up against...)
In helping my dad, my main assets were better eyes and smaller hands. (My willingness to pretend to understand while he talked himself through the problem was also useful.) He would give me lots of seemingly irrelevant parts and a rag and have me clean them. Meticulously cleaning all the parts he was disassembling was our main activity. This irritated me, as I felt it was needlessly making the job take much longer. His claim was that many times simply taking apart the problematic assembly, examining it, cleaning it, and reassembling would mysteriously fix the car. He also felt that because there was no other time when these parts would get cleaned, that cleaning everything we had an opportunity to clean was a necessity as a matter of principle. This all seemed very anal to me at the time, and I would make sure to not call his attention to any dirty part he had not noticed.
Of course, I now feel exactly the same way about code cleanliness. I fix code by cleaning it. And when cleaning it alone does not fix it, it's easier to fix it after I've cleaned it. Through cleaning it I examine it thoroughly, finding any serious errors. By cleaning it I fix not just the bug I came for but the ones that weren't reported yet. And I don't just clean one function, but the entire assembly and the pieces I saw on the way to it. Often I see my job as one of deleting code more than writing it.
Cleaning code has many levels from fixing minor coding standards violations and deleting stale debug code to closing security holes through to major refactoring. As an open source developer I get to work with a lot of different code written by a lot of people with widely varying degrees of code hygiene, and I'm always able to submit a patch. The dirtiest code is usually found in the custom Drupal modules and themes desperate clients bring us for rescue after unwittingly hiring amateurs. Sometimes when I'm done cleaning out the rotten spaghetti in thousands of lines of code, trying to understand what it was ever intended to do, I find what's left could have been accomplished with a standard Drupal setting. Often entire functions and files exist in dirty code that are completely unused. Code can be much dirtier than old cars, and no amount of fast orange will clean it out from under your fingernails.
Jody is a full stack Drupal expert. She does technical architecture, strategy, development, consulting, and developer training. Jody has worked on hundreds of Drupal projects since she began as a freelancer in 2006 and co-founded Zivtech in 2008. Jody grew up in the Philadelphia area and graduated from Harvey Mudd College in California in 2000.
View the discussion thread.
Tell us about your project