Good Programming Practices - PowerPoint PPT Presentation

About This Presentation
Title:

Good Programming Practices

Description:

Comment your code such that it is clear what you code does ... In Dr. Scheme, debugger is useful for checking values of variable in the middle ... – PowerPoint PPT presentation

Number of Views:13
Avg rating:3.0/5.0
Slides: 9
Provided by: web77
Learn more at: http://web.mit.edu
Category:

less

Transcript and Presenter's Notes

Title: Good Programming Practices


1
Good Programming Practices
  • rules every programmer should know and follow.

2
Documentation
  • Comment your code such that it is clear what you
    code does
  • You should be able to figure out your code years
    after its written
  • A good programmer should be able to figure out
    what your code does from your comments.
  • Scheme comments start with
  • this is a comment
  • this is another comment

3
Documenting a procedure
  • Include
  • A description of what the procedure does
  • Type of arguments -gt type of return value
  • Constraints that need to be satisfied by
    arguments (requires clause)
  • Expected state of computation at key states
  • You should also include notes on what a
    particular chunk of code does if it may be
    confusing to a reader.

4
Documenting a procedure
  • Example

5
Documenting an ADT
  • Whenever you make an ADT, you should include some
    comments giving an overview of the ADT
  • You should describe each sub-unit of the ADT,
    including the type of the sub-unit

6
Documenting an ADT
  • Example

7
Debugging Using Test Cases
  • Whenever you make a procedure, you should write
    tests for it.
  • Test the procedure on limits of legal values
  • Test the procedure with arguments that span legal
    values
  • Include a comment with each test case indicating
    what you are testing

8
Debugging Useful techniques
  • Sometimes, you can use display or print to print
    out values of your variables at key stages of
    computation
  • Useful for isolating problem spots
  • In Dr. Scheme, debugger is useful for checking
    values of variable in the middle of a computation.
Write a Comment
User Comments (0)
About PowerShow.com