Production-Grade Code

November 8, 2022

Tom Zika (@Zikato25) asks “What quality makes code production grade?

And… I’m not sure I know the answer.

I’m a consultant, so I see quite a lot of organisation’s “production code”. The quality they have in common is that it’s code that’s in production. That’s pretty much it.

I know in the days when I used to code JavaScript occasionally, there was the concept of “minifying” the code, which made a tighter version of it all, so that it would load better. This was code that was good for production. Hopefully most of the tests were happening on the minified code, because if that’s what was going into production, then you’d want to be sure that it worked, even if the pre-minification code worked fine. If you deployed code that wasn’t minified, then that wasn’t right.

But SQL doesn’t really have that concept. I don’t need to remove excess whitespace from my queries for the sake of performance.

I know that before code goes into production it should be tested properly. I’d like it to be bug free, and to have had all the edge cases included in the testing. I’d like the queries to be ones that compile to good query plans. Fast plans. Plans that I’m not ashamed of. Or that are good enough, at least.

But production-grade code? Hmm.

In his invitation, Tom mentioned the phrase “this is not production-grade code”. And I find myself a little curious about that. What makes something fail this?

Does it imply that it’s in production and shouldn’t’ve been? Did it fail the testing regime? If that’s the case, it shouldn’t’ve been deployed to production.

Does it imply that it’s not ready for testing but has been submitted for testing?

My guess is that “not production-grade” implies that it’s code that’s in production, but that the company style guide hasn’t been followed. Or that there are comments related to debugging included in the code. Something like that.

I think if beauty is in the eye of the beholder, and art is subjective, then whether or not something is “production-grade” is going to depend on the opinion of the person responsible for the code. Probably not the coder who wrote it.

It’s not going to be a defined thing. But they’ll know it when they see it.

Tom wants us to provide advice to newbies who want to know what makes the grade or not. And my advice is this:

Read code that the company considers production-grade code.

It’s said that the way to be able to detect counterfeit bank notes is to study the legitimate ones. It’s less about learning what things are the signs that money is fake, and more about becoming so familiar with what is good that you can instinctively tell that something’s not right.

If you want to write good code, read good code.

If you want to write good technical documentation, read good technical documentation.

Learn to spot the signs that something in your organisation will be accepted as production-grade, by reading other code that has. Then when you look at your own code, does it feel like it’s production-grade, or not? It’s hard to assess your own work, but hopefully you can take a step back and figure it out.


Leave a Reply

LobsterPot Blogs

Blog posts by Rob Farley and other LobsterPot Solutions team members.


Related Blogs