Programming Style Guide
Introduction
This page outlines common FlatRedBall coding standards for consistency and clarity these should be followed when writing code for any first-part FlatRedBall game, FRB Editor, FRB Engine, or any other FRB application. In other words, if you are checking in any code to a FlatRedBall repository, follow these standards.
General Programming
Brackets
With the exception of single-line getters and setters in properties, brackets should be on their own lines.
Correct:
Incorrect:
Incrementing and Decrementing Values
The ++ and -- operators for incrementing and decrementing should always occur on their own lines. Correct:
Incorrect:
Exception: Compound statements are ok in for-loops:
Use temporary variables to avoid complex statements
Each line of code should do one thing. Do not use method calls inside of other method calls, or complex logic inside of other blocks of code.
Correct:
Incorrect:
Limit use of "value"
The "value" keyword in properties is necessary for setters, but it should be used as little as possible inside properties. The reason for this is because it makes migrating code outside of properties into separate methods more difficult. In practice this usually means that the field represented by the property should be set first, then it should be used in any code that follows.
Correct:
Incorrect:
Class Layout
Access Modifiers and Static
Access modifiers should be listed prior to modifiers such as static.
Correct:
Incorrect: