Programming: you're doing it wrong
The year 2010 marks the twentieth anniversary of my professional involvement with the IT industry; in two decades, I have learned that programming, more than any other profession below “Keith Richards,” seems to attract people who have a certain ego. I don’t mean to say that we’re all megalomaniacs in search for a country to run, but there certainly is no lack of opinionated types in our industry.
The result is that a programmer who wants to make a name for herself soon finds out that it takes an extremely thick skin to survive in this world—even if you try your best to avoid being caustic, chances are that others around you won’t. In the world of computers, people have to volume settings: loud, and extra loud. To borrow lamely from pop culture, our amps all start at eleven.
The question is: why?
One of the things that I have learned in twenty years of attempting to program is that we’re all doing it wrong. You. Me. Everybody.
No matter how advanced the techniques that we use, there is always something that we could be doing better. Do you think that static methods are convenient? Sure, they work—but His Holiness Martin Fowler has decreed that Singletons are the correct way of handling static data. Except, of course, that he also told us that dependency injection is a much better way of handling external dependencies.
Which one is right?
The real problem is that the answer to that question is, “yes.” That’s because it lacks a specific context in which it can be inserted. Dependency injection may be the correct answers in some situations, while singletons may be perfect for your needs in others. Without in-depth knowledge of the circumstances in which a particular problem presents itself, there is no particular way to offer a definitive solution.
Meanwhile, in the Bat Cave…
While we stand and argue the finer points of computer science, we often lose sight of our primary mission: enabling processes. A programmer is first of all an artisan: proud of her work, but most productive when she is making something.
Somewhere along the lines, we’ve somehow managed to convince ourselves that we are artists. We have stopped debating differences on their merits within the context of enabling us to get things done—instead, we argue them endlessly in the abstract, as if writing code were both means and end. Like the CIO who sets a company’s IT strategy based on what’s on the back cover of the latest issue of Information Week, we’re moving from fad to fad without stopping to consider that technology is a tool and not a substitute for our own responsibility to make choices.
Meanwhile, those who somehow manage to remember that software is a tool achieve great success even if their code leaves a lot to be desired. When I open a PHP file inside the WordPress codebase, I feel like I just boarded a time machine that’s taken me back to the way we used to write PHP code six or seven years ago—and don’t even get me started on what I think of Drupal.
Yet, despite the fact that their code looks like it was written by someone who has no idea who Martin Fowler is and probably thinks that dependency injection is a medical technique for weaning addicts off of opiates, both those products undeniably work, and work well—not to mention the fact that they are very widely used.
More than that, they’re actively maintained, updated and upgraded—despite the fact that, according to what the artists tell us, software written using less-than-optimal techniques should be unmaintainable, buggy and unreliable.
If you’re agonizing over whether you’re writing good code, let me spare you the anguish: you’re doing it wrong—except if your code works, in which case you most definitely are doing it right.
Image credit: Adam Swank