正確處理 Exceptions: 不要直接 catch generic Exception
不要使用Finalizer (try-finally)
private static final
; public abstract final
...m
.s
.lower case letter
.For example:
public class MyClass {
int mPackagePrivate;
private int mPrivate;
protected int mProtected;
private static MyClass sSingleton;
pubilc int publicField;
public static final int SOME_CONSTANT = 42;
}
When naming test methods, you can use an underscore to seperate what is being tested from the specific case being tested. This style makes it easier to see exactly what cases are being tested.
For example:
testMethod_specificCase1 testMethod_specificCase2
void testIsDistinguishable_protanopia(){
ColorMatcher colorMatcher =newColorMatcher(PROTANOPIA)
assertFalse(colorMatcher.isDistinguishable(Color.RED,Color.BLACK))
assertTrue(colorMatcher.isDistinguishable(Color.X,Color.Y))
}