Repository navigation
Coding Conventions
André edited this page Mar 21, 2022
·
28 revisions
The coding convention helps create a consistent look for the code. Readers will understand the code more quickly and it facilitates copying, changing and maintaining the code.
In this project, we use several naming conventions.
Be aware that
protectedelements are treated the same way aspublicelements
Always use pascal casing ("PascalCasing") when naming classes, structs, properties and methods.
public class MyClass { }
public struct MyStruct { }
public int MyInteger { get; set; }
private void MyMethod() { }Always use camel casing ("camelCasing") when naming private fields and method parameters.
public class MyClass
{
private bool myBoolean;
public void MyMethod(int myParameter) { }
}A good layout uses formatting to emphasize the structure of your code and makes the code easier to read.
- Use four-character indents and save TABs as spaces.
public struct MyStruct
{
----private int myInteger;
}- Write only one statement per line.
- Write only one declaration per line.
- Continuation lines should be indented one time only.
var myObject = new MyClass(0,
40.0f,
"text");- Use parentheses to make clauses in an expression apparent, as shown in the following code:
if((value1 > value2) && (value1 > value3))
{
// Block of code to execute if the condition is true
}Getting Started