-
Notifications
You must be signed in to change notification settings - Fork 2
Code design guidelines
We understand that people contributing to Bricklayer are at different levels of coding experience, however we want to set a standard to be used throughout the code.
All code should be as object oriented and extendable as possible, we would rather not see hardcoded values, strange class structures, and, to put it blunt, crappy coding.
Commenting code is always good, try and comment your code, not always what it does, but why it does what it does. Sure, PingTheServer() pings a server, but why? Try and explain what the intended purpose of your code is.
Protip: In Visual Studio, Type 3 forward slashes ///
, before a method or class name, to generate a nice summary of information (Which can be used in documentation files, useful for the API)
We will add to this list over time, based on what we see, but here are a starters:
- Adhere to the standard C# guidelines for naming:
- Methods, constants, public variables and properties should be in PascalCase
- Private fields should be in camelCase
- Classes should be named by nouns or noun phrases
- Don't use hungarian notation
- etc, etc, http://msdn.microsoft.com/en-us/library/xzf533w0%28v=vs.71%29.aspx
- Give variables and functions meaningful names, this
LoadClientSettings(string file)
is much better thanLoad(string str)
- Don't nest ternary operators, no one wants to see this:
int value = something ? 10 : whatever ? something : 5
- When working with large strings, or large numbers of them, use
StringBuilder
rather thanstr + str
- Guide Unfinished, More coming soon.
- Split long lines into multiple lines, we shouldn't have to scroll horizontally.