-
Notifications
You must be signed in to change notification settings - Fork 3
Codingstyle
lickx edited this page Sep 10, 2018
·
5 revisions
Variables are prefixed with their type:
- integer iMyInt
- string sMyString
- vector vMyVector
- rotation rMyRot
- list lMyList
- float fMyFloat
Booleans are written as iMyBoolean
Global variables get an additional prefix: g_
- integer g_iMyInt
- string g_sMyString
Constants don't have a prefix and are written in ALL_CAPS:
integer LOCATION_FLAGS = 31;
Function names are camelcase without prefix for the return value:
integer MyFunction(string sMyParam)
We use four spaces to ident, not tabs!
Here the project is less consistent
Try to avoid inline brackets:
if (x) { DoSomething(); DoSomethingElse(); }
OpenSim might choke on nested conditional statements if no brackets are used on the outer condition:
if (x)
if (z)
DoSomething();
else
DomSomethingElse();
else
AnotherThing();
This should have been written as:
if (x) {
if (z)
DoSomething();
else
DomSomethingElse();
} else
AnotherThing();