2014-07-30 18:00:46 +02:00
|
|
|
Zombie:Reloaded Code Guidelines
|
|
|
|
===============================
|
|
|
|
|
2015-03-29 17:23:06 +02:00
|
|
|
General Notes
|
|
|
|
-------------
|
|
|
|
|
2014-07-30 18:00:46 +02:00
|
|
|
This is a draft of coding guidelines for Zombie:Reloaded. If something is not
|
|
|
|
mentioned here, study the existing code to ensure consistency.
|
|
|
|
|
|
|
|
Most of the code was written before we decided on the code style, so we may even
|
|
|
|
break our own rules according to this document.
|
|
|
|
|
|
|
|
Highly recommended book:
|
|
|
|
Clean Code: A Handbook of Agile Software Craftsmanship (2008)
|
|
|
|
Robert C. Martin
|
|
|
|
|
2015-03-29 17:23:06 +02:00
|
|
|
Formatting:
|
2014-07-30 18:00:46 +02:00
|
|
|
* Curly braces on separate lines.
|
|
|
|
* Indent with 4 spaces instead of tabs (configure your editor).
|
|
|
|
* Unix line endings.
|
2015-03-29 17:23:06 +02:00
|
|
|
* Always use curly braces with control statements (if, for, while, do, switch).
|
2014-07-30 18:00:46 +02:00
|
|
|
* UTF-8 file encoding without BOM.
|
2015-03-29 17:23:06 +02:00
|
|
|
|
|
|
|
Conventions:
|
|
|
|
* Try to use good names for variables and functions. By looking at the name
|
|
|
|
alone, it should be obvious what the function does or what the variable
|
|
|
|
contains.
|
|
|
|
* Extract code into multiple single-purpose functions if the code is too
|
|
|
|
complex. Then it's also easier to come up with good names. ZR is still bad at
|
|
|
|
following this rule.
|
2014-07-30 18:00:46 +02:00
|
|
|
* If the code needs comments, it should be refactored/renamed to better explain
|
|
|
|
what it's doing. ZR has a lot of unnecessary comments, mostly because it's not
|
|
|
|
following the single purpose-function rule above.
|
2015-03-29 17:23:06 +02:00
|
|
|
|
|
|
|
|
|
|
|
Console Variables
|
|
|
|
-----------------
|
|
|
|
|
|
|
|
Create wrapper functions for console variables (cvars) to avoid tight coupling
|
|
|
|
between cvars and logic.
|
|
|
|
|
|
|
|
Do create new cvars instead of hard coding settings.
|
|
|
|
|
|
|
|
See examples in src/zr/ztele/cvars.inc.
|