Style - Josh-McMillan/Community-Game GitHub Wiki
Code Styleguide
This document is not final and is currently a WIP and should be treated as a general guideline for now while it is still being decided upon.
Note: Wherever possible, we are following Microsft's official .NET style and naming conventions, which are simplified for C#. This is simply a quick glance reference for the most basic elements; when in doubt, check the offical Microsoft documentation.
Field Names
Field names are not to be prefixed with Hungarian notation. After a team vote we have decided to forego Hungarian notation in favor of the official conventions for C# and .NET programming.
camelCase variable names and PascalCase methods for consistency.
Do not shorten words, abbreviate or use acronyms in variable names where not explicitly appropriate (use your best judgement). Good code is readable, and your variable names are no exception.
Indentation & Braces
The official C# style guide generally recommends the following:
- Write only one statement per line
- Use default editor settings
- Write only one declaration per line
- Indent continuation lines
- Have at least one blank line between method definitions and property definitions
- Use paranthesis to make clauses apparent, ie. ((val1 > val2) && (val1 > val3)) rather than (val1 > val2 && val1 > val3)
Additionally, {INSERT BRACE STYLE ONCE DECIDED UPON} is preferred in this project, but not enforced.
Typing
Avoid implicit typing wherever it is not explicitly preferable - always specify the datatype of your variables, so that any developers working with your code can always tell what type something needs to be at a glance.
This does not apply as a strict rule when initializing the object on the same line, but even in this scenario, explicit typing is still preferred.
Statics
Use static members only when they are the most useful options; prefer singletons over static classes.