Layout | C Plus Plus Standards
Summary
Define how to layout code, how to use certain syntax and generally how code looks more than how code functions.
1. Public Classes, Methods, Variables and Accessible attributes should be commented.
Where there is any ambiguity at all, public attributes found within the engine should be commented. This means that classes, methods, properties, structs, enums and the values contained should all be considered for comments.
1. Example
1. Reason
Our code is going to grow large and is to be used by many people. We should attempt to help them by leaving breadcrumbs of knowledge to the truth of our code.
2. Context braces own their own line.
When defining a new context using { } braces, these should always go on a new line.
2. Example
2. Reason
It should be clear what context you are in at any given time.
3. Code lines should not take up too much space - keep it short!
When writing lines of code, they should not trail off into the right side of the screen such that scrolling to the right becomes the norm. Use method level stack variables to shorten the names, or break the line where needed to keep it short!
3. Example
3. Reason
Long lines are more difficult to comprehend. Additionally, the detail in lines tends to be on the right side, therefore you want this detail to be seen not hidden.
4. Public first in headers
Always start a new object with public.
4. Example
4. Reason
The Public facing behaviour of a Class is the most important. Sell it first.