|
@@ -0,0 +1,55 @@
|
|
1
|
+Style guide
|
|
2
|
+================================================================================
|
|
3
|
+
|
|
4
|
+This document aims to give a brief introduction to the code style we try to use
|
|
5
|
+in DMDirc. Having a consistent style makes it easier for developers to read code
|
|
6
|
+and reduces conflicts and excessive changes caused by individual style
|
|
7
|
+preferences.
|
|
8
|
+
|
|
9
|
+If you have any comments or suggestions about these guidelines, please raise
|
|
10
|
+an issue or open a pull request.
|
|
11
|
+
|
|
12
|
+## General
|
|
13
|
+
|
|
14
|
+* Lines should not exceed 120 columns
|
|
15
|
+* Java source code is indented using 4 space characters
|
|
16
|
+* Trailing whitespace should be removed
|
|
17
|
+* Braces should always be used even when optional (`if`/`while`/etc blocks)
|
|
18
|
+* Braces should open on the same line as the block begins (`if (...) {`)
|
|
19
|
+* `@Override` should be used whenever possible (including interface
|
|
20
|
+ implementations)
|
|
21
|
+* British English is preferred over American English
|
|
22
|
+
|
|
23
|
+## Imports
|
|
24
|
+
|
|
25
|
+* Do not import classes just for JavaDoc references (use fully-qualified names
|
|
26
|
+ instead)
|
|
27
|
+* Imports are split into non-static and static, separated by a blank line
|
|
28
|
+* Imports are then sorted lexicographically (in alphabetical order), with no spaces
|
|
29
|
+* Do not use wildcard (*) imports
|
|
30
|
+
|
|
31
|
+## Constructors
|
|
32
|
+
|
|
33
|
+* Constructors should be the first method defined in the class
|
|
34
|
+* Explicit default constructors should be avoided unless required
|
|
35
|
+* Explicit calls to `super()` in constructors should be avoided
|
|
36
|
+
|
|
37
|
+## Methods
|
|
38
|
+
|
|
39
|
+* Method annotations should each be on a separate line
|
|
40
|
+* All modifiers should be in the order recommended by the JLS:
|
|
41
|
+ `public`, `protected`, `private`, `abstract`, `default`, `static`, `final`,
|
|
42
|
+ `transient`, `volatile`, `synchronized`, `native`, `strictfp`
|
|
43
|
+* Method-level synchronisation should be avoided in favour of `synchronized`
|
|
44
|
+ blocks on private objects
|
|
45
|
+
|
|
46
|
+## Documentation
|
|
47
|
+
|
|
48
|
+* All classes should be documented using javadoc
|
|
49
|
+* Author names should not be included, and should be actively removed if present
|
|
50
|
+* Methods should be documented unless their function is extremely obvious (e.g.
|
|
51
|
+ getters and setters)
|
|
52
|
+* Methods overriding a superclass/interface may omit documentation to inherit
|
|
53
|
+ the parent's
|
|
54
|
+* `{@inheritDoc}` should only be used when adding extra information to a parent's
|
|
55
|
+ documentation
|