Putting the Building Blocks All Together - PowerPoint PPT Presentation

1 / 6
About This Presentation
Title:

Putting the Building Blocks All Together

Description:

... for classes, methods, and variables ... Variables and method names: Use lowercase. ... For example, the variables radius and area, and the method computeArea. ... – PowerPoint PPT presentation

Number of Views:40
Avg rating:3.0/5.0
Slides: 7
Provided by: lvan2
Category:

less

Transcript and Presenter's Notes

Title: Putting the Building Blocks All Together


1
Putting the Building Blocks All Together
2
Programming Style and Documentation
  • Comments
  • Comments are very important. You should comment
    your code in order to provide explanations of
    what the program is doing
  • Indentation and Spacing
  • Proper indenting makes the code reflect the
    actual logic of the program.
  • Block Styles
  • Placement of the and braces
  • Naming conventions
  • Use descriptive names for classes, methods, and
    variables
  • By convention, class names begin with uppercase,
    method and variable names begin with lowercase,
    and constants are all uppercase.

3
Comments
  • // for single line
  • / / for multiple lines
  • Comment at top of source file to identify the
    author and the purpose of the program
  • Comment to describe classes, methods, and
    sections of code (steps of the algorithm)

Comments help readers understand the program code!
4
Indentation and Spacing
  • Statements within blocks should be indented
  • Statements that are executed within control
    structures should be indented
  • If a statement continues from one line to the
    next, the subsequent line(s) should be indented.

5
Block Styles
  • Choices
  • Next-line
  • void myMethod()
  • ---------
  • End-of-line
  • void myMethod()
  • ---------

Either way is fine
6
Naming Conventions
  • Variables and method names
  • Use lowercase. If the name consists of several
    words, concatenate all in one, use lowercase for
    the first word, and capitalize the first letter
    of each subsequent word in the name. For example,
    the variables radius and area, and the method
    computeArea.
Write a Comment
User Comments (0)
About PowerShow.com