Coding Conventions

posted by: Ms. Martin 15 September 2010 One Comment

Below are the coding conventions I will hold you responsible for this year.  This is a living document and will be revisited as we learn more syntax.  Feel free to comment if you disagree with any thing or would like to add something.  For reference, Sun’s recommended code conventions can be found here.

What I value most is CONSISTENCY.  There is some variability allowed here as long as you are consistent.

Naming

Names must always be descriptive of the element they represent.

Classes – nouns in mixed case with first letter of internal words capitalized
class Raster
class ImageSprite

Methods – verbs in mixed case with first letter lowercase and first letter of internal words capitalized
run();
runFast();

Variables – mixed case with first letter lowercase and first letter of internal words capitalized

Indentation

Increase level of indentation after all opening curly braces

Stay at a single level of indentation for an entire block

Close curly braces at the same level as the corresponding opening curly brace

Other formatting

Each class must have a comment in this format:
/* Name:
Date:
Assignment:
Description blahblahb
*/

Start a new line after every ; or }

Skip exactly one line between methods

Main must be at the top

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 1.00 out of 5)
Loading ... Loading ...

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>