Universal Communication

Universal Communication

Part1 - Code Readability, Writability and Maintainability

What are coding standards

Coding standards are collections of rules,techniques and guidelines that determine the programming style, procedures, and methods that will be followed for a project. When standards are decided on they need to follow industry and organization set best practices that will be implemented by a group of programmers to create cleaner, more readable and more efficient code. Standards offer a uniform format by which software engineers can use to build and understand sophisticated and highly functional code.

When working as a team, it is crucial to set rules and guidelines that each member on the development team must follow to ensure that the product is reliable and maintainable.

This article focuses on the impacts coding standards have on code readability, writability and maintainability

How to apply coding standards on projects

Naming conventions

Naming conventions is how your variables, classes, methods,folders and files should be named within your project. Examples of well known naming conventions are camelCase, PascalCase or snake_case.

Comments and documentation

Code may be read and reviewed by individuals who are not necessarily developers , this implies they will not instinctively understand what they are reading without clarification. Developers are also human, and it is a lot easier for them to read comments describing how the code functions rather than scanning the code and making speculations.

Ensure that the comments guide any readers through the algorithm and logic implemented. Of course, this is only required when the code’s purpose is not apparent. Don’t bother leaving comments on self-explanatory code.

Appropriate naming of files and folders and their organization Software project structure and layout needs to be set up using best practices, this produces a cleaner and maintainable code base with files and folders found in the correct places within the project rather than an unstructured project which will result in problems affecting maintainability,integration and deployment of the software product.

Formalize exception handling

Exceptions refer to problems, issues, or uncommon events that occur when code is run and disruption on the normal flow of execution occurs. This either pauses or terminates program execution, which is a scenario that must be avoided. Keeping the code in a try-catch blocks helps avoid this situation and aids in managing exceptions as they occur.

Follow the DRY (Don’t Repeat Yourself) principle.

Reuse repetitive tasks and blocks of code whenever necessary. The same piece of code should not be repeated in the script. Avoid long lines of code. It is easier for humans to read blocks of lines that are horizontally short and vertically long. Don’t use lengthy functions. Ideally, a single function should carry out a single task. Setup code templates for reusability.

Use tools and technologies

We can also set up and utilize well known industry tools to make our projects follow set coding standards. For example the team can set up Linters like esLint or Ts Lint which are static code analysis tools used to flag programming errors, bugs, stylistic errors and suspicious constructs. We can use prettier as a code formatter to also standardize the code base.

We can also utilize version control tools like Git and Github to setup build pipelines that scans scripts and identifies any unstandardized code.

Performing Code Reviews

Testers and Reviewers should review code to ensure it follows the set standards and to check if the code works and does what it needs to do before it is merged into a stable development or production branch. Following software engineering standards like merge requests or pull requests and code review sessions allows reviewers to be able to effectively review the submitted code.

Following programming language and community set best practices Languages have coding standards that are enforced by the language implementation, programming languages provide style guides which are set guidelines on how to write programs which follow standards set by the programming language creators, maintainers and community members Eg. Python PEP 8

Study and discussions with engineers

Question1

Who should come up with coding standards?

[Answer] Programming language documentation provides style guides or the best coding standards a language should follow when it is used and written by engineers. [Answer] Companies should have their own set coding standards they intend their developers to follow. [Answer] Tech leads should also decide on which standards a project will follow when it is designed and set up. [Answer] The whole programming team should be involved when decisions on which standards to follow are being made.

Question2

How have coding standards affected your development process?

[Answer] They make the development process a bit difficult, there is a lot of time wasted trying to follow standards instead of solving the problem. This negatively affects the agile process that is usually followed by software development processes. [Answer] They make the workflow of development much easier. This is because it helps when you try to maintain code because it is more readable and clean. [Answer] Standards help streamline the communication and understanding between devs on projects. It introduces room for simplicity and efficiency as decisions on the best constructs to be used can be made. Eg. using switch statements over if-else blocks. [Answer] Setting up coding standards may be a time consuming exercise. People may find it difficult to decide on which standards to use as they may have conflicting views on the best way to implement programs. Tools being used may not be set up properly on all machines working on a project.

Conclusion

In order to have the best readable , writable and maintainable project, coding standards need to be decided on and set up for each project. We can safely say coding standards facilitate the universal communication between developers.