A Quick Guide on ‘STYLE GUIDES’
Style guides are certain conventions used to improve the readability and consistency of a code.
Consider major projects that involves a large group of developers adding chunks of code to the project, if everyone follows their own convention then finally when the code is pulled up, it might look hasty and also due to inconsistency it may result in error. The problem might seem nothing in a smaller scenario, but when we take into account thousands of developers, the code runs into thousands of lines and these inconsistency can cause huge issues.
Thus, Style guides are setup by the companies that are to be followed by all their employees while writing codes, so that there exists consistency.
While setting up these standards everyone should be kept in mind, the entire team should be taken into account while doing so.
Every programming language has it’s set of style guide. Like for Python there is this PEP 8,a document that gives coding conventions for the Python code comprising the standard library in the main Python distribution. Some other style guides are:
- Google python style guide: Google has it’s own set of conventions for different languages.
- TensorFlow style guide: Follows PEP8 Python style guide, except for using 2 spaces.
- NumPy style guide
Some common conventions in most of the style guides are:
- Maintaining proper indentation.
- Maintaining a white space after a comma, semicolon or colon.
- Limit on the length of any line in a code.
- Conventions on comments.
There are various linting tools to verify codes and point out the errors or deviations. Pylint is one of the tool that takes care of python codes and verifies whether the code style stands out to the coding conventions laid out by PEP 8.
Many projects have their own coding style guidelines. In the event of any conflicts, such project-specific guides take precedence for that project. The main idea behind all these style guides is to improve readability, thus the developers can sometimes go off the conventions and have their own style of coding but that should not create problems to other.