Java Programming Guidelines
Instructor: Kurt Mammen
Java provides an excellent coding style that most programmers follow. You should actually browse through it to see what a robust industrial-grade coding style looks like. For this course we will use a very simple coding style to 1) Make your life - and mine - easier, and 2) To get you in the habit of following a coding style.
Note that part of the grade for your programming assignments may be based on following these guidelines! Get in the habit of following these guidelines in all your work so that it becomes second nature for you. If you have any questions or concerns about the guidelines bring them up with your instructor in lab or office hours before handing in your work!
if
(i == 0)
{
// Your code here...
}
The Java guidelines prefer this style:
if (i == 0) {
// Your code here...
}
if (i == 0)
{
j++;
}
Never this! (even though it is syntactically and semantically correct)
if (i == 0)
j++;
And never this! (even though it is syntactically and symantically correct)
if (i== 0) j++;
NEVER suppress compiler
warnings unless an assignment explicitly permits it - and then only
suppress those explicitly permitted by the assignment.