Home > Articles > Programming > Windows Programming

  • Print
  • + Share This
From the author of Talking with the Face in the Mirror

Talking with the Face in the Mirror

It's easy to blame someone else, particularly managers who prevent you from doing the right thing. But sometimes the real enemy may actually be you.

I've been guilty of writing horrible code. Looking back at some of the code I've written over the years, I wonder how I could have been such an idiot. Even today, someone may point out problems with some of my code, and I'm embarrassed to see my name in the comments of such an example.

Why did it happen? Usually, I wrote the worst code when I was in a hurry, or working on the ninth hour of a ten-hour day. Maybe I didn't have accountability to a coding partner who would ridicule my crappy code. Perhaps I lacked a build system that would register a broken build if code coverage went below a certain percentage.

Essentially, I was doing the most expedient thing, versus doing the right thing:

  • I could have employed alternative systems that have been proven to work, such as setting up success criteria (tests) before starting to write code. But to the uninitiated, writing tests first seems weird and counterintuitive.
  • I could have allowed a design to change as I learned more about a domain. But if you're schooled in traditional waterfall methodology, letting a design evolve seems almost irresponsible.

Our industry often makes "silver bullet" promises that fail to deliver. But I've been guilty of the same error committed by many programmers: I've outright rejected the practices of test-driven development just because they're different. Equated my (initially low) comfort level with this new technique with its likely effectiveness. For years, my personal biases led me away from very strong evidence that test-driven development actually works.

Overcoming this bias is really an exercise in asking yourself to try something—even if it's outside your comfortable frame of reference. Even though it means a little more pain for us in the short term, that's better than opting for giving our employers lots of painful (read: expensive) maintenance in the long term.

  • + Share This
  • 🔖 Save To Your Account