Programming Style
Programming Style
NAMING CONVENTIONS
Classes
o Name should be descriptive
o Capitalize the first and second words (ie TempConverter)
Variables
o Do NOT use generic names (your names should almost represent selfdocumentation) (ie firstName)
o Lowercase the first letter and Capitalize subsequent words
o Do NOT use more than 15 characters
Constants
o Use meaningful names that help with self documentation
o Use ALL_UPPER_CASE for your named constants, separating words with
the underscore character. (ie TAX_RATE rather than taxRate or TAXRATE).
Methods
o Name should describe the meaning of the method
o Use mixed case first letter lowercase and subsequent words Capitalized
(ie calculateIncome)
o Are your methods getting or setting something you may want to prefix
the name with this (ie setIncome)
Parameters
o Use the same naming conventions as you did the above
o These are values that you will be passing into methods; therefore, you
may want to prefix the name with a or an (ie aDeposit)
COMMENTING
Heading comments
o //name of the assignment
o //what the program is to do
o //your name
o //date completed
Segments of code
o Include comments that describe what segments of code are performing
Methods
o //description of what the method does
o //pre-conditions
o //segments of code (as above)
o //post-conditions
Add comments as you goit will make it easier to debug
Always place the comment before the statement
FORMATTING
MISCELLANEOUS
Your input statements must be descriptive (you may use print or println)
Use println to print blank lines to separate input and output on the console (always
check your output with the samples)
You must format your output and have a statement
All programs should include error trapping