This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 121
Code Style
mastercoms edited this page Dec 24, 2014
·
9 revisions
This page documents code style guidelines. For general contributing guidelines, see CONTRIBUTING.md.
- Generally, follow Oracle's formatting standards (alt link).
- The indentation should solely consist of 4 spaces instead of tabs.
- No trailing whitespaces for code lines, comments or configuration files.
- No CRLF line endings, only LF is allowed.
- For Windows-based machines, you can configure Git to do this for your by running
git config --global core.autocrlf true
. - If you're running a Linux or Mac OSX, you should run
git config --global core.autocrlf input
instead. - For more information about line feeds. See this article.
- No 80 character line limit or 'weird' midstatement newlines.
- Avoid nested code structures.
- All files must end with a new line.
- Use import * if you import 4 or more classes from the same package.
-
@Override
methods should not have docs. They inherit their parent's docs. - Public and protected methods on public classes should have docs.
- Private methods should have docs when their function is non-obvious.
- Public classes except protocol internals should have docs.
- Fields on classes that are not simple data structures should have docs.
Basically, when in doubt, docs.
- In the message codecs, each read from the buffer should be assigned to a variable before the message is constructed. Avoid constructs like
return new XMessage(buffer.readInt());