DEV Community

George Hanson
George Hanson

Posted on • Originally published at

Why Are Coding Standards Important?

Almost every language has a set of standards that developers advocate. Off the top of my head and coming from a PHP background, PSR standards spring to mind. These standards are essentially a set of rules on how you should name your files, variables, classes and even non-naming issues such as line length.

But why are these standards important? I mean if it works isnโ€™t that the main thing? Why do I have to follow these strict rules that tell me how I should code!?

Well, hang on a minute letโ€™s put the brakes on. Coding standards are important, but it is important to know why you should be doing them, rather than just following them because you feel like you should.

Why are coding standards important?

Coding standards are there for a reason. They are designed to try and make the code you write as maintainable as possible. I want to especially emphasise this if you are working within a team. If you are all following the same set of rules on how you should write your code, it is far easier for other developers to understand it, contribute to it and to help maintain it.

But it is not just for those within teams.

It is also important if you are working solo. Even if it is a project that will never be shared with anyone. By consistently following these standards, if you stop working on a project and come back to it 6 months later it will be far easier to understand the code instead of having to spend hours or even days reading the code trying to understand what is happening.

Having knowledge and experience in coding standards is also beneficial for getting hired. Companies like to know that the code you write can easily be maintained by other developers in the team. Or if you were to leave, that another developer could come along and understand what you are doing.

Coding standards arenโ€™t there to be a hurdle you have to jump over. They are there to stop the headache down the road. If you start using them, it will become muscle memory and you wonโ€™t even realise you are doing it.

This article was originally posted here:

Top comments (6)

matthew_collison profile image
Matthew Collison

Code standards that follow the community agreed guidelines (e.g. PSR in PHP or Google's JS style guide) are the sign of an excellent programmer.

People have any number of objections like the fact they have their own style, or they have a personal preference, but it's very short sighted because chances are your code will be picked up by someone else in the future. And when it is, if it is consistent with community guidelines, you save a million headaches for that other developer.

So spend the 2 weeks it takes to research community standards and adopt them - your peers will appreciate it. Unless your code will never see the light of day outside your own eyes!

ferricoxide profile image
Thomas H Jones II

Coding standards also help with ensuring that code-linters work ...and, by extension, that your code is mostly going to do what you think it's going to do - whether under conditions you expected or didn't.

That said, some of the standards feel like they make it like a lot of a given programmer's "personality" is washed away.

ronancodes profile image
Ronan Connolly ๐Ÿ› 

Having consistent code formatting matters.

Imagine reading a book where the fontface, font color, font size, and line indentation was different on every paragraph.

It would be difficult to read, and incredibly difficult to update (maintain) and find typos (bugs).

jessekphillips profile image
Jesse Phillips

I have a standard for you. Don't commit formatting changes.

Seriously many of the standard conventions I see come because people have a hard time reading one style or another, and I suppose mixed style. These types of coding standards suck for me because I literally don't even see them. And I don't want to train myself to see them.

devit951 profile image

Yeah, I use java standards as much, as possible.

ronancodes profile image
Ronan Connolly ๐Ÿ›  • Edited

I use the Angular and TypeScript standards.
Best to go for what the language/framework you're using recommends.