Now that the team has grown, we want to make sure we keep our style consistent, following the modern C# and Unity conventions developers are acquainted to.
So today, the team and I are proud to announce the official raywenderlich.com C# style guide!
Let’s take a look at what’s inside.
At this point, the guide is fairly basic. It contains guidance on the following items:
- Case. Case can be confusing – sometimes it’s best to use camelCase, and sometimes it’s best to use PascalCase. We try to clarify what’s best where.
- Code blocks. Indentation should always be done using spaces. Blocks of code should always be indented 4 spaces.
- Braces. All braces get their own line. This follows the C# convention and improves readability. Conditional statements are always required to be enclosed with braces, irrespective of the number of lines required.
- Switch statements.. Never include the
defaultstatement, this only clutters up the code and should be removed.
To learn more, check out the full C# style guide.
Where To Go From Here?
We know everyone has a different opinion on a certain style of code and we’d love to hear yours!
If you have any suggestions on how to improve this code even further, post issues on the GitHub page or file pull requests – I’ll be watching for them, and if you can convince me (and the rest of the team), we’ll change the guide.
We hope you like the new and improved C# style guide – you can look forward to some awesome Unity tutorials coming up that will be using it! :]