Why is it important to follow Coding Standards and Coding Conventions?

Andrey Diskin
November 28, 2024

Not once or twice have I heard things like, “Why should I follow this? It works just fine for me,” or, “I know what’s best for this project, why should I follow their conventions?”

It’s easy to ignore coding standards and conventions as unnecessary, especially when everything seems to be working well for you. But here’s the thing: a codebase with consistent styles and patterns isn’t just about personal preferences - it’s about creating an environment that’s easier to work with, understand, and maintain.

So, what’s the difference between coding standards and coding conventions? In simple terms, standards are formal rules that ensure code quality & consistency across projects, while conventions are agreed-upon practices for style and structure of a language or a project. 

For example, a language convention in JavaScript or TypeScript is to use camelCase for variables, so you wouldn’t use kebab-case. On the other hand, a project convention might be to use camelCase for folder names, even though folder naming doesn't have a universal standard, unlike variables or functions. If the project adopts this convention, you should follow it.

An example for coding standards in action is using simple tools like ESLint (a linting tool that analyzes your code and provides feedback as you type) and Prettier (a formatter for consistent style). While these might seem trivial to you, they enforce coding standards and help catching common errors early, and it's much easier to review and maintain code that is formatted and well-organized.

But why does this matter? consistent code isn’t just about aesthetics - it makes the code easier to read & review. Imagine working on a large team where everyone uses their own styles. Reviewing code would become a nightmare, and onboarding new developers would take longer. Tools like linters catch issues early, and formatted code saves precious time during code reviews.

In the end, following coding standards and conventions isn’t about limiting creativity, it’s about making collaboration easier and creating software that’s simpler to maintain and grow. Think of it as a shared language - one that makes sure everyone on the team is speaking the same "dialect". That’s how great software gets built.

Andrey Diskin
November 28, 2024