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.
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: https://www.georgehanson.co.uk/blog/why-coding-standards-are-important