mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-08-03 19:17:27 -04:00
Created CodeConventions (markdown)
parent
d5b2c3ce2b
commit
dee7fbcbd8
43
CodeConventions.md
Normal file
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
|
||||
```
|
Loading…
x
Reference in New Issue
Block a user