1 / 6

Documentation and Style

Documentation and Style. Documentation and Comments. Programs should be self-documenting. Use meaningful variable names. Use indentation to show program structure. Use comments to explain what the program is doing. Comments in Java.

jodie
Download Presentation

Documentation and Style

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Documentation and Style

  2. Documentation and Comments • Programs should be self-documenting. • Use meaningful variable names. • Use indentation to show program structure. • Use comments to explain what the program is doing.

  3. Comments in Java • Anything following a double slash (//) on a line is considered a comment, e.g., double radius; //in inches • Anything between the symbols /* and */, no matter how many lines are included, is considered to be a comment, e.g., /* This is a comment */

  4. Program Comment Header • It’s good to put a comment header block at the beginning of each separately compilable piece of code. For example, for this class you might have a header like the following: /* Purpose: to determine the area of a circle Author: Jane Q. Programmer E-mail Address: jqprogrammer@csun.edu Programming Assignment: #3 Last Changed: January 6, 2006 */

  5. Placement of Brackets and Indentation • One convention for the placement of brackets was demonstrated in the code examples in Programming Project #1. • A second convention is used in the textbook. In this approach the matching brackets are lined up in the same column. • The code inside each set of brackets is indented.

  6. Naming Constants • Place the keywords public static final in front of the declaration setting the value of the constant, e.g., public static final int PI = 3.14159; • By convention constants are named using all capital letters.

More Related