-
Notifications
You must be signed in to change notification settings - Fork 0
Style Guide
Tabs are fine for indentation
One space after keywords like if
if (condition)One space (no newline) between brace and bracket
int method() {Name variables in snake_case because they're easier to read
int some_variable;Name constants with ALL_CAPS
final int SOME_CONSTANT;Additionally, use the constants that are in ALL_CAPS if you have a choice
color = Color.WHITE;Name methods in camelCase
void someMethod()Name classes in CamelCase as well, but with first letter capitalized
class SomeClassSpaces between math operators + * - / << >> & |, but no extra spaces with [] () <> brackets
Also, use the parent interface when inializing things like lists or sets, and don't use explicit type arguments
array[i] = method((i * 1337 + 420) / 69 - 12);
List<String> string_list = new ArrayList<>();Dont declare arrays C-style
int[] a = new int[4];(not int a[] = new int[4];)
When declaring an array literal, place a space between the square bracket and first curly brace, but not inside the curly braces
method(new int[] {1, 2, 3});Use key bindings, not KeyListeners
getInputMap().put(/* key */, "action");
getActionMap().put("action", new AbstractAction() { ... };