Coding Standards: Lightbulbs in Programming

20 Sep 2018

Thomas Edison is often quoted for saying something like, “I have not failed. I’ve just found 10,000 ways not to make a lightbulb.” It is a quote that makes you re-assess your ideas on failure and success, and one of many that seek to inspire people to persevere in the face of great hardship. And in our journeys as programmers, I’m sure we’ve all found much more than 10,000 ways not to solve a problem!

Besides trivial things like syntax errors and typos, the first hurdle people face in writing code is usually the algorithm. Countless functions were born at the union of, “How do I return that?” and a thinking emoji. With enough experience and programming knowledge, solving many problems can get pretty fast—not to mention the countless ways of solving such problems. But the flexibility that programming languages give us to solve problems also provides a vast solution space that is not always easy to navigate when we look at someone else’s code. While it is impossible to truly step into the mind of someone else, there is something that can help minimize the infinitely-many ways to write code: coding standards.

Coding standards are guidelines that encourage programmers to write code in a recommended style. This makes it easier for others to read their code because it establishes a protocol to format solutions that everybody can get on board with. When you have every other person asking someone else, “So what did you mean when you wrote this code here?” it tends to get incredibly problematic when scaled up to even moderately-large software projects. The coding standard provides a protocol that, once you learn it, helps make everybody’s job easier. Think of it as a list of inside jokes that you need know in order to understand why everybody is laughing in a group you’re new to.

Coding standards also help reduce complexity in code. While intuitiveness and elegance may be subjective, we have all run into some code that used way, way too many lines than necessary to solve some problem. Coding standards give collaborators a way to stay grounded and in-sync when approaching problems, and can even lead to great learning experiences for programmers inexperienced in a domain.

In art, it is valuable to express yourself in unique and interesting ways, but it doesn’t work the same when programming in the workplace. Logistics is hard enough as it is when working amongst even a small team of people, but efficiency in communication and understanding is absolutely essential to achieve things in a collaborative setting. Coding standards act like a lightbulb in a dark room, providing a clear set of guidelines to streamline expression and get everybody on the same page. Such a unity of thought and action is a powerful ideal for any team—those who reach it become unstoppable forces, no matter the industry or motive.