A recent tweet by Smashing Magazine about mistakes got me thinking about all the times either myself or a colleague had made a significant mistake. I’m not talking about a white-space error here. I mean the sort of mistake that gives instant, sinking nausea. Your heart sinks and your stomach knots up as the realisation comes crashing down; I did this, and the only way out is through.
You see, I’m a great believer that “mistakes maketh the developer”. I’m pretty sure that @phpcodemonkey is tired of hearing me say it at every opportunity. I appreciate that there are many facets to a developer, but a key one for me is dealing with disasters or better yet, avoiding them totally. So even though you can recite a good Fowler book off by heart, it’s no good to me if you become some trembling wreck in the corner because a MyISAM table crashed. Don’t get me wrong, I don’t want to work with Inspector Clouseau, constantly wrecking things as he makes his way around a system, but let’s say I’m skeptical of a developer who can’t provide a juicy anecdote to “what’s the worst mistake you’ve ever made?”
A friend of mine (no really, it wasn’t me) issued an UPDATE statement on a table with 6.5 million rows … without a WHERE clause. Perhaps the worst casualty of this episode was his pride; in that particular instance, it was the communal “dev box” so impact was minimal. In the next few years I worked with him, he never made the same mistake again and I bet he’s never done it since. I know I haven’t and I certainly don’t intend to any time soon (touch wood).
And so what happens now?
Every seasoned developer starts with a SELECT, works their way to a satisfactory set of criteria, then changes the SELECT to an UPDATE. That, to me, is the sign of someone who has been stung by a run-away UPDATE statement. Stitch in time saves nine an’ all that jazz. There are lots of other work patterns which may seem inefficient at first but once you have the back-story from a developer, it would make sense.
What’s your point?
Isn’t there some sort of stack overflow-esque repository of cautionary tales, categorised by technology which can be used when training junior developers I’d like to combine the conciseness of Clients From Hell, the anecdotal tech focus of The DailyWTF, and the tagging/categorisation of your average WordPress blog. If the repository got large enough, imagine the huge collective wisdom stored within. You could have a Friday afternoon activity where your team finds good stories and presents the set up, the point of failure and the preventative cure. Suddenly, all developers are benefiting from others’ mistakes.