Coding Standards

4. Comments

7. Design Heuristics

8. Exceptions

1. Source Files - Filename matches Class name

2. Source File Structure

/*
 * Course: CS1011 - 021
 * Fall 2015
 * Lab 2 - My First Program
 * Name: Brad Dennis
 * Created: 10/13/2015
 */

3. Special Characters - Never type a literal tab

4. Comments

/**
 * This method prints out "Hello" to the person given and
 * returns the number of letters in the person's name.
 *
 * @param name The person to who to say hello.
 * @return The number of characters in the person's name.
 */
while(isDone==false) {
    // ...
    if(str.length()>0 && str.charAt(0)=='A') {
        isDone = true;
    } 
}

write

while(str.length()==0 || str.charAt(0)!='A') {
    // ...
}

5. Formatting

public void someMethod(int argumentOne) {
    if(argumentOne<=0) {
        doSomething();
    } else {
        doSomethingElse("Perhaps the best way to deal with " + argumentOne + 
                        " pieces of pizza is to eat them.");
    }
}

6. Rules of Programming Discourse

7. Design Heuristics

Example Class

A complete class example, is provided in the Complex class implementation in the CS1011 classes tutorial.

Acknowledgement

This coding standard was developed by the MSOE software engineering faculty and is based upon Java Style Guide published by Google and other sources.

CheckStyle

The CheckStyle plugin should be used to help ensure consistency with the coding standard. Here are the steps for installing the plugin in IntelliJ:

  1. File -> Settings -> Plugins
  2. Search for "CheckStyle" and click "Search in repositories", if shown
  3. Select CheckStyle-IDEA and click "Install"
  4. Restart IntelliJ
  5. File -> Settings -> Tools -> Checkstyle
  6. Click on + to add a Configuration File
  7. Enter MSOE for the Description
  8. Select "Use a Checkstyle file accessible via HTTP" and enter https://faculty-web.msoe.edu/jones/MSOE_checkStyle.xml
  9. Click Next and then Finish
  10. Click the "Treat Checkstyle errors as warnings" box
  11. Ensure that the checkbox for MSOE is selected and click OK
  12. File -> New Project Settings -> Settings for New Projects
  13. Tools -> Checkstyle
  14. Repeat steps 6-11 for this screen