Created CodeConventions (markdown)

Florian Nücke 2014-01-27 04:28:45 -08:00
parent d5b2c3ce2b
commit dee7fbcbd8

43
CodeConventions.md Normal file

@ -0,0 +1,43 @@
If you'd like to contribute code and save me the work of reformatting stuff (which will also make it more likely for it to be pulled!) please try to stick with the following conventions:
Lua
===
- Be consistent.
- Indent using spaces, two wide. Do indent properly.
- Try to limit width of the code to 80 chars.
- Don't add spaces between braces/brackets and what's in them.
- Do use brackets in functions calls even if it's not necessary.
- Name variables for what they are, don't include type markers in them, i.e. *do not* use Hungarian notation.
- Nice to have: sort your requires alphabetically (OCD!)
- Only comment if it's something complicated/non obvious. Keep in mind that comments increase file size, which increases the amount of ram required to run your program!
Bad:
```lua
function f(sArg1 , ... )
print(sArg1)
if sArg1 then
local nResult = 1
--do some more stuff
return nResult
end
end
if f ( "a" ) ==1 then
print"asd"
end
```
Good:
```lua
function f(arg1, ...)
print(arg1)
if arg1 then
local result = 1
-- We extrapolate the b-spline of the non-euclidean space to
-- determine the fraction of potential failures encountered.
return result
end
end
if f("a") == 1 then
print("asd")
end
```