“How Do I Know the Quality of My Code?”

Whether you’re using contractors or you have your own development team, chances are you’re going to wonder at some point whether or not the quality of your code is up to par.

As you’re learning by now, almost every part of software development is a nuanced topic. Quality is no exception.

The Problem with Measuring Quality

Code quality is one of the more contentious topics in software development. Here’s a post from Stack Overflow that helps to identify the issues. In short, it doesn’t matter what systems you put in place to measure code quality. Developers will adapt their work to “game” the system, not necessarily improving the overall quality of the project.

For example, if you use test coverage as the metric, developers will write more tests, but not necessarily more quality tests. If you base it on bug fixes, the team will classify more things as bugs and fix more. Human nature kicks in and the behavior conforms to what’s being measured. When you combine this with the fact that every developer has their own opinions about style and method, it gets to be an overwhelming mess. Many business and product owners end up completely frustrated and default to hoping the quality is at least acceptable.

The good news is that you can implement a few simple practices and tools to give you as the business owner at least a sniff test of the kind of work your team’s doing. It won’t be perfect, and you’ll probably encounter some righteous indignation along the way, but you will persist through it.

How to Sniff Test Your Code

Here are three ways to begin assessing the quality of your project.

#1: Pay attention to issues reported by your users

This may seem obvious, but I have seen over and over that owners delegate the handling of user issues entirely. Especially in the early-going, doing at least a daily review of what your users are saying is one of the best ways to assess how the team is doing. If every time you do a release you get a slew of new bugs, you can be pretty well assured that your quality is not where it needs to be.

#2: Use quality measurement tools

There are a number of tools out there to assess quality. I’ve personally used SonarQube, which is open source, and Codacy, a code-inspection-as-a-service offering.

SonarQube is typically run on your infrastructure and requires more time to set up and configure. However, it supports more languages and has been around longer than some of the other options. It’s also free and open source.

Codacy is my current favorite because if you host your project on Github, you can have your first code inspection report about three minutes after you sign up. Like lots of other services, you pay by the month based on the number of projects you’re inspecting. However, they don’t support as many languages as tools like SonarQube.

I’ll be doing a deep dive on each of these products in a future post to give you an in-depth explanation of how they work in detail.

#3: Ask someone else for their opinion

One of the best ways to get a free assessment of the quality of your code is to have whomever you’re hiring review the source code and give you five things they would change if they owned the project. More often than not you’ll gain some valuable insight just by having someone outside your org look at the work.

If you’re not hiring, then ask around in your network for someone you can trust to spend an hour or two going over your code and give you back a report. Even if you have to pay for it, it’s worth the peace of mind to have someone else’s eyes on the work. Senior-level developers can go through a project very quickly and highlight areas of concern. I’d do this once every few months in the early going to ensure you don’t waste a bunch of money.

Just Remember

  • Code quality is, at some level, a subjective exercise. However, for every language there are commonly accepted standards that your code should meet
  • Using code inspection as a hammer to beat your developers over the head will only result in them gaming the results to meet your demands. Instead, treat any code inspection result as the starting point of a discussion on how to improve.
  • Use all of the resources available to you such as bug reports, code inspection tools, and outside opinions, you can get a valid sniff test of the overall quality of the work

Your Assignment

  • Meet with your team and assess the current state of quality, as well as how they believe quality can be measured.
  • Implement one of the tools I mentioned above in the next week or two to get an initial, automated report of how you’re doing
  • Share the results of the report with me or one of your technical advisors and assess next steps