-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathcodingStandards.java
98 lines (80 loc) · 2.73 KB
/
codingStandards.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import java.lang.String; //import specific packages, not *'s
/**
* This file is both an example and explanation of adopted coding standards.
* These standards are mandatory for code check-ins on github and will be
* rejected if they are not followed. This may seem harsh but coding standards
* ensure everyone is on the same page.
*
* Code comments should accompany any nonobvious methods describing WHY the method
* is doing what it does. If you need to describe WHAT it is doing, your code is
* wrong.
*
* Methods should be no longer than 10-15 lines. You should be able to describe the method
* without using the word "and". Any longer indicates a need for refactoring or
* poor design descisions.
*
* file layout should go as follows:
*
* 1. imports
* 2. class declaration
* 3. private final/static vars no public vars
* 4. private mutable ivars no public vars
* 5. default constructor
* 6. constructor overloads
* 7. static methods
* 8. instance methods
* 9. getters/setters
* 10. OPTIONAL main methods for testing
*/
/**
* Java style block comments are used for classes and methods
*/
class CodingStandards //classes/interfaces/enums begin with uppercase letters and cammel case
{ //braces go on the next line, aligned vertically
private final int USEFUL_CONST_NAME = 1; //constants are in all caps and snake case
private static String extremelyDescriptiveName = "bob"; //camel case
private int usefulName; //ivars are ALWAYS private and cammel case
//names should be descriptive, prefer verbosity to terseness.
public CodingStandards() //default constructor
{
}
public CodingStandards(int descriptiveName, int overlVariable) //constructor overload
{
}
public static String fetchUsefullConstName() //static methods go after constructors
{
return extremelyDescriptiveName;
}
/**
* Nonobvious methods should have appropriate java style documentation to
* accompany them.
*/
public void doSomethingNonObvious()
{
}
public static void main(String[] args) //main methods may be used for quick testing if necessary.
{
assert 1 : 1; // primitive testing
}
// Getters / Setters --------------------------------------------
int getUSEFUL_CONST_NAME()
{
return USEFUL_CONST_NAME;
}
static String getExtremelyDescriptiveName()
{
return extremelyDescriptiveName;
}
static void setExtremelyDescriptiveName(String extremelyDescriptiveName)
{
CodingStandards.extremelyDescriptiveName = extremelyDescriptiveName;
}
int getUsefulName()
{
return usefulName;
}
void setUsefulName(int usefulName)
{
this.usefulName = usefulName;
}
}