Java Coding Guidelines
Java Coding Guidelines

      Unless told otherwise, you should always adhere to the
      following guidelines when creating your Java programs:

1) Use the sandbox code editor to create all of your programs. 2) Use the default editor fonts and colors (including the white background). 3) Put your name (first and last), course name, color/period, date, and program name in that order on the first five lines of every submitted file. 4) Put the 'main' method near the top of your code, before all other methods. 5) Keep 'main' sparse, putting most of your code into other methods. 6) Put a blank line between every method and between different sections of code. 7) Make sure each method has a single, clear, identifiable task. 8) Give every method a brief comment explaining its purpose. 9) Give every non-trivial/obvious variable a comment explaining its purpose. 10) Use descriptive, meaningful names for methods and variables. 11) Begin class names with capital letters, and method and variable names with lowercase letters; additional words in the names should begin with capitals. 12) Use the modifiers 'public' and 'private' to control access to methods and variables, giving only as much access as is needed for the program to run. 13) Use 'System.out.println()', 'System.out.print()', or 'printf()' for all screen console output. 14) Use the 'Scanner' class to obtain all user input. 15) Unless told otherwise, you do not need to error trap user input. 16) Make sure your programs are easily readable and understandable. 17) After completing each assignment, unless told otherwise, turn in a printout of the file(s), making sure no lines of code automatically wrap to new lines. If your printout consists of multiple pages, staple the pages together.

Common Beginning-Programmer Errors -- Fix Them Yourself!!!
  • Use == for comparisons (not =)
  • Put parentheses around 'if' and 'while' comparisons
  • Do not put a semicolon at the end of most 'if' lines and 'for' lines
  • Do put a semicolon at the end of most lines of code
  • Match up all opening and closing braces
  • Remember that order matters when passing arguments into methods
  • Start method and variable names with lowercase letters, but capitalize     the first letter of additional words in the names
  • Capitalize the first letter of class names
  • Properly indent lines of code, especially within loops and between braces