CodingStandards - ScottLilly/SOSCSRPG GitHub Wiki
These are the coding standards to use in your pull requests.
Some of the existing code may not follow these standards. If it doesn't you can submit a pull request cleaning up the code to conform to the standards. However, please do that in a pull request that is separate from any changes. That makes it easier to review.
Naming convention
- Constants: UPPER_CASE_WITH_UNDERSCORES
- Classes/functions/properties: PascalCase
- Private class-level variables: _camelCase
- Private static class-level variables: s_camelCase (helps to identify that you may need to add a lock, when using the variable in a function)
- Lower-case second (and subsequent) letters when the variable name is an abbreviation: Xml, Sql, Id
- Variables declared in the code-behind, or a business/service class, should never be prefixed with datatype.
- XAML control names can be prefixed with datatype (btn = button, lbl = label, etc.)
Code blocks
- Always wrap code blocks with curly braces, even if they are only one line.
- The opening curly brace goes on a new line.
Unit tests
- Test projects names should match the project they are testing, with a prefix of "Test."
- The tests for the SOSCSRPG.Engine project should be in the Test.SOSCSRPG.Engine project
- Test names should start with "Test_" and give a descriptive name of the functionality they are testing
General
- Always add visibility: private, internal, public, protected
- Don't prefix variables with "this."
- Don't use "var"
- Don't use public/internal fields. User a property instead
- Use Environment.NewLine, instead of "\r" and/or "\n"
- Set the class/function/property function visibility as restricted as possible