w1 Codingstandards
w1 Codingstandards
Coding Standards
In the real world, programmers usually work in teams and often the company that they
work for has very precise rules for what kind of style to use when writing programs. For
this reason, and to encourage good programming style habits, we will be adopting the
following style conventions for this class. This is not to say that these rules represent the
only good style for writing computer programs. However, to earn full points on your
programming projects in this class, you must follow these guidelines. The rules are
meant to help train you to fit in with the professional programming community. With
time you will grow to appreciate that the rules will also help you to understand and write
your own programs.
To get started we’ll keep the rules in context learning what we need to know for each
week’s programming constructs.
That said, know for now, that style rules exist and be sure to follow the guidelines
presented each week for your labs.
Documentation:
Program Header: Include a program header comment that identifies your solution.
Information to include here: Your name, Class, Date and a concise description of what
the program does.
Indentation:
Not to use tabs for spacing; rather set your IDE to insert 3 spaces.
Align statements within a code block (i.e. corresponding statements within a code block
are not staggered).
Be sure not to flush source statements on the left margin. A good guide is to follow the
indentation scheme used in the textbook.
Blank lines:
Use a single blank line if line spacing is meaningful (i.e. separating variable declarations
from the method code block).
Other rules:
Use descriptive words for variable names (i.e. not single letters).
Begin class names with a capital letter and capitalize the first let of each word (e.g.
SampleClassName).
Keep source line length < 80 characters maximum. This is important so as not to create
long lines that will cause wraparound in some editors.