Code is Always Sacred

Over the years I've noticed that coders who show examples on their blog or in a presentation "cut corners". They'll do things like:

  • Use poor variable names, like foo or quux.
  • Fail to use proper coding idioms, like disposing streams.
  • Demonstrate terrible conventions, like having a catch block that does nothing.

Usually, they'll call this "demo code". Meaning, "oh, this is just showing the concept. You wouldn't do this in practice."

I call shenanigans.

Just because you're in front of a crowd doesn't mean the quality of your code can be less. If anything, it should be pristine, a shining example of how you should write code.

I've been guilty of this in the past myself. But I've really been trying to make an effort to show good code when I present [1]. And when I see presenters showing the latest and greatest coding styles and ideas without a lot of care behind the code, I cringe.

Let's always write code like it's meant to be the best we can do with our current knowledge base, no matter what the context is.

[1] Of course, there are exceptions. When I'm demonstrating bad code...well, then I have to show how not to do it!

* Posted at 01.08.2009 08:49:36 AM CST | Link *

Blog History