This repository was archived by the owner on Jan 18, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Code Style
gotonode edited this page Nov 20, 2018
·
4 revisions
This page lists all the coding style rules enforced by Checkstyle.
This rule is currently NOT IN EFFECT.
A magic number is a number that is used in code that is not a -1, 0, 1 or 2. Magic numbers should be replaced with constants that are defined elsewhere.
Incorrect:
if (http.errorCode == 404) {
something();
}Correct:
private final int NOT_FOUD = 404; // This is a constant value and can never be changed once set.
if (http.errorCode == NOT_FOUND) {
something();
}We write the opening brace on the same line, not on the following line.
Incorrect:
if (true)
{
something();
}Correct:
if (true) {
something();
}In Java, String comparison should be done using 'equals' and not by simply using '=='.
Incorrect:
String a = "meaning";
String b = "meaninglessness";
if (a == b) {
something();
}Correct:
String a = "meaning";
String b = "meaninglessness";
if (a.equals(b)) {
something();
}Course: Ohjelmistotuotanto 2018
Bookmarks Database
by Return Zero