Cpsc 121 06 format and style guidelines



cpsc 121 07

The Computer Science department has the following guidelines -- javaDocs style commenting. So, we will gradually adopt them as we learn new programming concepts.

AT TOP

“””

//@ file Name of the file

//@ author Name of author (with username in parentheses)

//@ date Date last changed

//Prog# - Description of the program

“””

blank line

any imports

blank line

function header, documentation, and body

blank line

function header, documentation and body

blank line

(main program now will be within a function called main, the last function)

def main():

at the bottom, you will call main

main()

documentation for each function to appear below the header

“””

//@ short description of what it does

//@param A line with the parameter name and its description

(Each parameter should have its own line)

//@returns Any returned value

//@usage How the function is called

Example:

def leibniz (numTerms):

“””

//@ approximates pi using an infinite series discovered by Leibniz

//@ param: numTerms: the number of terms used from the series

//@ returns: a finite sum approximation to the series

//@ usage: pi = Leibniz (100000)

“””

body for each function

code single-spaced unless it is long

then use a blank line to separate sections of code

do NOT use a blank line between every statement!!

other style guidelines

blank space before and after =

before and after arithmetic symbols

after a comma

NOT after a period

Indentation of 3-4 spaces to show program structure

Self-documenting names for functions, variables, objects,...

Program code should "read" close to English

For long variables, use case change or underline to show start

of new word Example: examTotal. Be consistent.

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download