T-SQL Tuesday #156 – Production-Grade Code

What quality makes code production-grade?

That’s the question posed by Tom Zika in this month’s edition of T-SQL Tuesday. I don’t believe there’s a “right” answer to this question but I do know there are plenty of opinions.

Check out the full invitation post by clicking the T-SQL Tuesday logo and read on below for my thoughts on production-grade code.


You understand what you’re thinking when you write code but will you remember it in a few weeks or months? What about the new associate that has to work with your code? Will they be able to decipher what you were thinking based on code alone?

If code isn’t documented, it can make work unnecessarily difficult. For production-grade code, I would expect it to be well documented so even someone with minimal knowledge can get an idea of what the code is doing. It’s not necessary to write a novel for documentation but having something is better than nothing.

Approval of Others

The phrase “two heads are better than one” applies to developing production-grade code.

Beyond just catching mistakes, more eyes and experience on code means a better chance of ending up with improvements. A more senior member of the team might know a better way of doing something which improves the code and is an opportunity for you to learn. Nobody is perfect. Leave your ego at the door and be open to feedback.

Error Handling

Expect the unexpected and assume that somehow there are going to be errors. Are you handling what happens when bad data gets passed in? What about when required data is missing and can’t be retrieved?

It’s better to get a more user friendly error message telling you what the problem is (or at least where to start) than getting something like “Object reference not set to an instance of an object” with no reference of a line number.

Production Doesn’t Mean Perfect

Even if code is documented, approved, and handling errors, that doesn’t mean there’s no room for improvement. Additional code changes might be needed due to growing traffic. Adjustments may be needed to handle larger amounts of data. Perhaps a new feature is getting released that can help optimize what was once a troublesome process.

Code making it to production doesn’t mean it’s code you’ll never see again so do yourself (and others) a favor by following the steps above.

Thanks for reading!

One thought on “T-SQL Tuesday #156 – Production-Grade Code”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s