Coding Conventions – 05/02/21

Coding Conventions, or rules, are a set of guidelines that help you write cleaner, more secure code. These guidelines can include:

  • Safe: It can be used without causing harm.
  • Secure: It can’t be hacked.
  • Reliable: It functions as it should, every time.
  • Testable: It can be tested at the code level.
  • Maintainable: It can be maintained, even as your codebase grows.
  • Portable: It works the same in every environment.

There are four key benefits to using coding conventions and they are:

  • They create a consistent look to the code, so that readers can focus on content, not layout.
  • They enable readers to understand the code more quickly by making assumptions based on previous experience.
  • They facilitate copying, changing, and maintaining the code.
  • They demonstrate C# best practices.

Coding Convention Examples in the Industry

Insomniac Games

Insomniac Games have their coding conventions published online, accessed through WebArchive.

https://web.archive.org/web/20170602083648/http://www.insomniacgames.com/core-coding-standard/

They use this coding standard so that across the board, whether you have been with the company for 20 years or have just started, the code is easy to read and is accessible. This makes the code easier to locate and debug where problems may occur.

Ronimo

Ronimo have their own convention, which is in detail over on this blog by Joost Van Dongen.

https://www.gamasutra.com/blogs/JoostVanDongen/20170711/301454/The_Ronimo_coding_style_guide.php

He states that there is an exception to every rule. However, keep to these rules as much as possible to maintain a constant layout and style for all the code and when writing a language other than C++, write it as close to C++.

Unity

Although Unity is a Game Engine and doesn’t specifically have their own rules for writing code, they do have a recommended way to writing code and how it should be written.

https://unity3d.com/learning-c-sharp-in-unity-for-beginners

In this document, they explain the fundamentals of coding and that writing clean precise code, can result in better performance throughout the games that have been created.

Leave a comment