Home
MyStruct.cs
1    /******************************************************************************
2        Style Guidelines:
3            * Readability - code is easy to read and to understand
4            * Standardisation - all team members are aligned with same code style
5            * Self-descriptive code - code is easy to understand without comments
6            * Debuggable - code is easy to debug (IDE friendly)
7     ******************************************************************************/
8    
9    // types are defined within the scope of namespace
10   // space name starts with Upper case letter
11   // each following word starts with upper Case letter
12   // sub-spaces are divided by '.' (dot)
13   // here "MyNameSpace" is main space and "Structs" is sub-space
14   namespace MyNameSpace.Structs
15   {    
16       /// <summary>
17       /// type name starts with Upper case letter
18       /// each following word starts with Upper Case letter
19       /// <remarks>
20       /// type = class, enum, struct, delegate. interface, etc
21       /// </remarks>
22       /// </summary>
23       public struct MyStruct
24       {
25           /// <summary>
26           /// static variable name starts with Upper case letter
27           /// each following word starts with Upper case letter
28           /// </summary>
29           public static float MyStaticNumber = 100f;
30   
31           /// <summary>
32           /// public variable name starts with Upper case letter
33           /// each following word starts with Upper case letter
34           /// </summary>
35           public double MyNumber;
36   
37           /// <summary>
38           /// public read-only variable name starts with Upper case letter
39           /// each following word starts with Upper case letter
40           /// </summary>
41           public readonly bool IsInit;
42   
43           /// <summary>
44           /// constructor name starts with Upper case letter
45           /// each following word starts with Upper case letter
46           /// </summary>
47           /// <param name="myNumber">
48           /// parameter name starts with lower case letter
49           /// each following word starts with Upper case letter
50           /// <remarks>
51           /// NOTE pay attention to letter case difference between 'MyNumber' variable and 'myNumber' parameter
52           /// </remarks>
53           /// </param>
54           public MyStruct(double myNumber)
55           { // <- opening parenthesis, new line after method name
56               MyNumber = myNumber;
57   
58               // function scope const variable name starts with lower case letter
59               // each following word starts with Upper case letter
60               // NOTE variable/const definition is close to it's usage scope 
61               const bool isInit = true;
62               IsInit = isInit;
63           } // <- closing parenthesis, new line after last method code line
64       }
65   }