IT Worst Case Survival Guide

How to Handle Code that did not Follow Standard Coding Guidelines

by: Precocity

While your initial urge to throw a voodoo curse on whoever hexed you with their non-standard code is well-deserved, don’t give in to the temptation. Follow the steps below to help redeem your rogue coder and show him or her the error of their ways.

Before you can fix the situation, you need to assess what you’re up against. Grab the code and throw it through your favorite code format checker. The report from the code format checker will tell you whether you’re up against a problem in the “tabs vs. spaces” camp, or something more serious. Formatting issues are annoying, but the code can still be salvaged.

If there are deeper problems, then it might be time for a heart-to-heart with the offending developer or your management team.

There are code beautifiers out there that will clean up even the ugliest formatting issues. These do require significant up-front work to define your standards in an appropriate configuration file, but they offer very real ongoing benefits.

Having the ability to transform ugly, non-standard code into compliant code with the press of a button can go a long way to smoothing out differences in coding styles amongst your developers.

It will also help you keep from tearing your hair out in frustration when you keep running into code written with spaces instead of tabs.

If the code is so insanely out of compliance with the standards that even the automated tools won’t save it, you’re going to have to get your hands dirty. The key here is to focus on the function at hand. Don’t try to fix an entire module if you’re only tweaking a few functions.

Bring the piece you’re working on into compliance with the standards, and then move on. It may not seem like you’re doing much by fixing a handful of lines of code in a project, but even the Great Wall was built one stone at a time.

In organizations with a lot of different developers, you are going to have conflicting styles from one person to the next. Forcing everyone to conform to standards is a great idea, but forcing them to do it on their own may just slow down their progress.

Rather than frustrating the whole team, look into applying tools to the problem. Require that every piece of code pass a code format check and be run through a beautifier before it gets checked in. Even better, automate the process so checking in code triggers the format and beautification process.

Coding standards make life easier for the company and developers who must alter or maintain a program. Their benefits aren’t always obvious to the current development team, which is focused on getting the work done and the project into production. Using tools and automation to implement coding standards satisfies the company without handcuffing and irritating the development staff.


Like what you see?

If you would like to chat about working on a project together or learn more about working with us, get in touch!