August 04, 2017

Tips & How To's

In Programming, Sweat the Small Stuff

by Jeff Camozzi

Programming is easy — especially if you don’t get caught up in all the little annoyances that make it take longer to code. Things like code reviews, standards, and practices. Who cares if your curly braces are on the right line, or whether your variables are clearly named? It’s much easier to just write code that solves problems than to spend the extra time to make it look “pretty” when the average user of your product will never even see the code…

As they say, don’t sweat the small stuff. Except… look, let’s be real, in programming, it’s the small stuff that always seems to get you. Whether it’s a misplaced punctuation, a forgotten semi-colon, an upper-cased letter that’s supposed to be lower-cased, the small stuff can consume an inordinately large amount of your time. Programming languages are a way to communicate ideas to computers, and computers are quite literal about how they process our communications. Having an eye for the little details, and a desire to address them, is how programmers help avert their own disasters.

The Semi-colon problem

My favorite piece of advice to my developers, old or new, is to beware the semi-colon problem. The premise is that, when things go topsy-turvey, and there doesn’t seem to be a cause, it will likely be some insignificant issue that is the culprit. Often this amounts to a typo in the wrong place, at the wrong time — or simply a missing semi-colon.

Semi-colon problems can leave developers tearing their hair out, convinced there is some magic voodoo breaking their perfect code. While veteran coders may still get caught by these issues from time to time, the most experienced of this breed always have an itchy hesitation when pushing the button on important code changes. Good developers will review their code and deployment instructions multiple times just to be extra certain it will work as expected. They know that even with a healthy dose of paranoia, things can go south quickly.

While I like to deride my team about these issues, they aren’t always laughing matters. Such issues can be costly, and so, finding ways combat them not only saves heartache for developers, but also saves money for your business.

What to do with all the small stuff

There are a number of practices we follow in the development community to enhance our focus on the small stuff. Coding standards, best practices, and code reviews are simply the first step. Teams must understand that the more we focus on the small details, the better the product becomes. Code is more readable, issues are caught sooner, and developers become more proficient. The focus on the small stuff leads to a better product, and a better team.

Having teams focus on the small stuff is great for improving quality, however, we’re all still humans, and as much as I’d like to believe we can be perfect at “the small stuff,” there will always be times where we replace every user’s password with “password” in the production database because we forgot the proper “WHERE” clause (wait, you haven’t experienced this? I mean.. this purely hypothetical…). Finding a way to sweat the small stuff in a consistent manner is extremely beneficial. Enter automation.

Automate the small stuff, so you can focus on the big stuff

Automation is a great buzz word. The idea is to use automatic processes over manual processes, thus eliminating the human element. What’s good for programmers is that many people have already solved problems for them. Things like code linters, static code analysis tools, unit testing, and automated QA testing all help to reduce the small stuff. Here are some great tools to get you started:

Code Quality and Review tools

Codacy / Code Climate / Code Beat / Sonar Qube

Having a way to analyze code quality gives developers and managers the ability track improvement over time, and ensure the codebase maintains a high level of quality. Many of the tools above provide an easy way to get started. These tools include the ability to automate some aspects of code review and ensure “the small stuff” doesn’t slip through the cracks!

Unit / Behavioral Testing Tools

Every programming language has a plethora of tools used for developer to test their code. There are different types of testing methodologies, so developers should find a tool that suits the style of their language and team. If you’re interest in a solution that covers multiple languages, check out Cucumber, which uses a Behavior-Driven Development approach with multiple language implementations.

Automated QA

Selenium / Appium /  Serenity / Robot Framework / Sahi

Taking manual steps out of QA processes lead to more consistency in the quality of a product delivered. While it may not be important to some developers that a small bug makes its way to users, some bugs can be damaging to a company’s reputation, and bottom line. There are a plethora of tools available to automate QA. While Selenium tends to be the de facto standard, any form of automation of testing will help catch the small stuff and allow developer to improve the product without having actual users be the “testers.”

Wrapping up

It’s easy to write code if you don’t worry about the small stuff, but it’s the small stuff that can sometimes have the largest impacts on your team, your product, and your company. The more you emphasize strong standards, and a “fix-it-now-not-later” mentality, the better your code will be. While automation can help, it must first start with you, the developer, owning the importance of addressing the small stuff.

The better you get at addressing the small stuff the sooner you can start sweating the big stuff.