C# Naming Conventions

C# Naming Conventions
Naming conventions are a often overlooked part of writing code. They are rarely taught to beginners often times because it can be considered as a dry and drab part of writing code. The same can be said about writing good comments in a program. Good practices while writing comments will be covered in the future.
Back to Naming Conventions.
They exist to help you and others to navigate your code and they also prevent a lot of common mistakes and pitfalls.
We will now go over the most common naming conventions that exist.
  • Pascal Case : All starting letter of each word is capitalized.
  • Camel Case : All starting letters of each word is capitalized except for the first word.
  • Snake Case : Each word is separated by an underscore. It can be upper or lower case.
*Note : In some circumstances each of these will be slightly modified.

Pascal Case - Places To Use

Namespaces : eg - namespace BitShiftProgrammer.Tutorial{....}
Classes : eg - class PlayerControl
Public Fields : eg - public string PlayerName
Properties : eg - public int Age { set; get; }
Methods : eg - void SayHello() {....}
Enums & Enum Values : eg - enum Moves { Up, Right, Down, Left, TopLeft, TopRight }
Interfaces : uses 'I' pre-fix before pascal case. eg - interface IDoMagic {....}

Snake Case - Places To Use

Constants : upper case version. eg - const int PLAYER_HEIGHT = 6

Camel Case - Places To Use

Method Parameters : eg - void SayHello(string helloData) {.....}
Method Level Variables : eg - void FuncOne { int valueForAge = 69; }
Private Fields : using pre-fix before camel case. eg - private string  _playerAge Or private string m_playerAge 
Support Bitshift Programmer by leaving a like on Bitshift Programmer Facebook Page and be updated as soon as there is a new blog post.
If you have any questions that you might have about shaders, C# or Unity development in general don't be shy and leave a message on my facebook page or down in the comments.
If you this type of stuff check out the C# tutorial posts : HERE.
For Unity tutorials, go HERE.
And more random topics, go HERE.