Hi, I'm Jeff Atwood from Coding Horror.

Alex offered me the opportunity to write an article for The Daily WTF while he was away on vacation a few months ago. Unfortunately, the scheduling never quite worked out, and the tone of the resulting article was different enough from The Daily WTF format that it never quite fit in. But now that the site has been relaunched, it’s a perfect time to revisit the question that has nagged at me ever since I wrote the original article. What are we all doing here?

I'm no stranger to bad code; after all, my blog is named after a sidebar illustration used to illustrate dangerous code in Steve McConnell's seminal programming book Code Complete.

But I'm not here to present yet another scary code sample by yet another developer who should have known better, but didn't.

Although I love Worse Than Failure like I love the world's ugliest dog, the concept has always made me a little uncomfortable. I've certainly written my share of WTFs through the years. And what exactly defines a WTF, anyway? One developer's clever hack is another developer's nails-on-the-chalkboard WTF.

Ultimately, I decided that Worse Than Failure makes me uncomfortable because it exposes the dirty little secret of our profession: we all write bad code.

The only difference between us and them, in fact, is that we know when we're writing bad code.

And that's a very thin line indeed.

There are millions of lines of WTFs written every year by developers who had no idea they were writing WTF material. The developers writing these WTFs are blissfully unaware of the carnage they're creating for their fellow developers.

And there's so much material to work with. In our profession, bad code is not remarkable, noteworthy, or interesting. Bad code is utterly mundane because it is, sadly, all too common. It's the status quo. If you want to see bad code, you don't have to come here to do so. Just look around you. This should make us uncomfortable. If anything, there should be a website where you could marvel at the truly unique code -- the stuff that doesn't suck.

Publicizing bad code is part of educating developers. Worse Than Failure has done that remarkably well. Pointing and laughing at all these terrible code samples is fun. But once you realize the scope of the problem, it stops being fun -- and starts being downright depressing. At some point you wish the guy before you had done something about this person and their WTF code before it became your responsibility.

Let's take a break from our regular programming to consider how we can prevent WTFs from happening in the first place. If you're reading this, you probably don't need our help. But your fellow developers do. Take less capable developers under your wing. Mentor them. Provide them with guidance. Invite them to a user group meeting. Email them blog links. Expose them to essential programming books like Code Complete and Don't Make Me Think. In extreme cases, maybe they legitimately picked the wrong profession and should be gently nudged into some other role.

Or you could just post their code on Worse Than Failure for us to laugh at.

But when you do that, you're really laughing at all of us.

 

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!