-
Notifications
You must be signed in to change notification settings - Fork 33
Coding Conventions
Mikael Kindborg edited this page Jun 26, 2015
·
7 revisions
Purpose of the coning conventions is to make it easier to understand and maintain the code.
- Indent using tabs
- Use descriptive names, avoid abbreviations is possible
- Keep placement of brackets and use of semicolons consistent within a file
- Aim for 80 character line length
- Comment key classes/functions to help people understand the overall structure
Here are some conventions that have been used by the JavaScript code in the "hyper" folder in the evothings-studio repo:
- Lines do not end with a semicolon (to reduce "line noise"), which is also common in Lua
- Variables that refer to modules are in CAPS to make it clear that they are modules
- Variables global within a module are prefix with "m"
Lines that start with a opening paren must begin with a semicolon to avoid joining of lines, like this:
;(...
Be aware that a new line after return makes the function return undefined.
This returns undefined:
return
1 + 2
This returns 3:
return 1 +
2