Skip to content

Code design guidelines

Cyral edited this page Mar 25, 2014 · 3 revisions

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:
  • Give variables and functions meaningful names, this LoadClientSettings(string file) is much better than Load(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 than str + str
  • Guide Unfinished, More coming soon.
  • Split long lines into multiple lines, we shouldn't have to scroll horizontally.