By now you are expected to have developed good programming habits, including the use of a consistent programming style. Since we will all be reading each other's code, it is necessary that we adopt some style conventions to make that task as easy and pleasant as possible. Some conventions are perhaps best adopted on-the-fly as the course proceeds and we determine the need for them, but here are some rules that must be followed from the outset:

  1. Every substantial program will identify itself and the responsible programmer(s), in some consistent and pre-approved format, either immediately upon startup, or indirectly by making this information available to the user via a menu choice. The fact that we said "substantial" program simply means that simple sample programs that are meant to illustrate one or two specific points may be exempt from this rule.
  2. All output displayed by a program will be well-formatted, and free from grammatical, spelling, punctuation and other similar errors.
  3. All source code files will be properly identified.
  4. All source code files will be adequately commented.
  5. All class methods will contain a statement of any necessary pre/post conditions.
  6. All code lines will always be short enough so as not to "wrap" when displayed or printed on an output device that displays or prints only 74 characters per line. In other words, the maximum length of a source code line will be 74 characters.
  7. Source code files will never contain a TAB character.
  8. Source code will be indented four spaces per indentation level, and properly aligned. This means that all statements at a given indentation level will be aligned at the left. If any such statement extends over more than one line, the second and subsequent lines of that statement will be positioned for maximum readability of the statement as a whole.
  9. Corresponding braces, also called "curly brackets", i.e., the symbols { and }, will always line up vertically.
  10. All identifier names will be well-chosen. In particular, all void methods will have a name containing a verb, and in almost all cases beginning with that verb.
  11. Class names will start with a capital letter, have each succeeding word also start with a capital letter, and will otherwise contain only lower case letters and possibly digits. (Examples: Menu, TextItems, Time24)
  12. Variable names and method names will start with a lower case letter, have each succeeding word start with a capital, and will otherwise contain only lower case letters and possibly digits. (Examples: numberOfGuesses, guess1, addOption) Class methods that get or set a class data member must begin with the words "get" or "set", respectively. (Examples: getText, setTitle)
  13. Named constants will be capitalized, with an underscore separating words. (Example: MAX_NUMBER_OF_GUESSES)