Java Coding Guidelines
Java Coding Guidelines

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

1) When in class, always use Eclipse to create and edit your Java programs. Outside of class you may use the CodeHS.com sandbox code editor to work on your programs. 2) Use the code editor fonts, colors, background, and formatting style provided by the instructor. 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) Properly and consistently indent lines of code, especially within loops, conditional statements, and braces. 8) Make sure each method has a single, clear, identifiable task. 9) Use descriptive, meaningful names for methods and variables. 10) Give every method a brief comment explaining its purpose. 11) Give every non-trivial/obvious variable a comment explaining its purpose. 12) Begin class names with capital letters, and method and variable names with lowercase letters; additional words in the names should begin with capitals. 13) 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. 14) Use 'System.out.println()', 'System.out.print()', or 'printf()' for all screen console output. 15) Use the 'Scanner' class to obtain all user input. 16) Unless told otherwise, you do not need to error trap user input. 17) Make sure your programs are easily readable and understandable. 18) Remember that every program that you submit must be designed and written entirely by you. You must never copy or receive code in any format from any other sources. 19) After completing each assignment, electronically submit your code file(s) via Google Classroom. In addition, unless told otherwise, turn in a printout of the file(s) using a fixed-space font and 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