COMP 103 Programming Style Guide

For your COMP 103 assignment submissions, you should adhere to basic coding style guidelines:
  • Have a descriptive documentation comment on every method
  • Use indentation to show blocks of code clearly.
    BlueJ has an auto-layout feature (-> Ctrl-Shift I) that you may use for this purpose.
  • Use meaningful variable and method names.
    Code becomes self-documenting when you use names like "elementCount" instead of "c". Note the use of "Camel case" for the compound name "elementCount". Use camelCase or underscores (for UPPERCASE_CONSTANTS) to make compound names more readable. Also see the Java Code Conventions.
  • Use meaningful comments in strategic places.
    Do not comment every line! For example, there is usually no need to explain the meaning of "count++;" but ensure that main design/implementation decisions are communicated to the reader of your code by concise descriptions.
  • Consistent use of { } and ( ) in the code. For instance the below examples are both acceptable ways of using { }, but not in the same piece of code. Be consistent how you use brackets.

   if (foo) {
      // do something
   }

   if (foo)
   {
      // do something
   }

The principles above must be followed to avoid mark deduction (up to 5 marks can be deducted for bad style).

For more information about good Java style, see the Google Java Style Guide.