Special Cases
Last updated
Was this helpful?
Last updated
Was this helpful?
Was this helpful?
Use the capabilities of your IDE - Turn on most of the possible warnings
Do not add new code with warnings!
Use code checkers - CheckStyle, FindBugs, PMD, Sonar, etc.
Example: Bad: Suppressed warnings
Example: Good: Fixed problems
Use correct logging levels
Log stack trace only for unexpected program errors
Create (concatenate) expensive message only if logged - see SLF4J capabilities
Never use raw types - always use generics correctly
Avoid using reflection
Know you API - use utility methods
// Many tricks for one unused parameter
// CHECKSTYLE:OFF
@SuppressWarnings("unused")
private void addDescription(Type type, Contract contract, String comment) { // NOSONAR
contract.setDescription(createDescription(contract.getType(), comment));
}
// CHECKSTYLE:ON
private void addDescription(Contract contract, String comment) {
contract.setDescription(createDescription(contract.getType(), comment));
}