CS324e Coding Standards


These are essentially Mike Scott's standards from CS 303e. Writing code that is easy for others to read is an important part of programming.  Failure to follow these standards is grounds for deductions on assignments.

  1. Object variable and primitive variable names will be meaningful.  The name of variable shall help describe its purpose in the program and / or what it is an abstraction of from the real world.

  2. Variable and method names shall not be all uppercase. No underscore or $ characters will be included in variable and method names.

  3. Constant names shall be meaningful and help describe what the constant represents.  The name shall be all capital letters with underscore characters used to separate internal words.  A good constant name would be DAYS_PER_YEAR.  A bad constant name would be THREE_HUNDRED_SIXTYFIVE.

  4. Class names shall start with an uppercase letter and internal words shall start with a capital.

  5. There shall be a space after keywords and surrounding all binary operators.

  6. Braces must be lined up vertically or horizontally.  This includes braces for a class, a method, and braces that contain a code block for if/else statements. (The only time braces may be lined horizontally are for methods that contain a single line of code).

  7. Statements in the same program block shall lined up vertically. To ensure this is correct no matter what editor is being used to view your code use either all tabs or all spaces.  Mixing tabs and spaces may cause the code to look good in your editor, but it may look bad in another editor if the tabs are set differently.

  8. Code shall be indented to show the code block it belongs to.  For example other than the class header and class braces, all code in a class shall be indented one tab.  So the header for the main method is indented one tab, as well as the braces for the main method.  The program statements and code inside the main method shall be indented two tabs.Code shall be indented to show the code block it belongs to.  For example other than the class header and class braces, all code in a class shall be indented one tab.  So the header for the main method is indented one tab, as well as the braces for the main method.  The program statements and code inside the main method shall be indented two tabs.

  9. Code in classes shall be in the following order:

    1. public methods

    2. private methods

    3. public static final constants

    4. private instance variables

  10. All private instance variables will start with the prefix my as in myMinutes or myDirection.

  11. Leave a blank line after every method

  12. Each class and method shall have a comment explaining what it does.


To the class home page