Presentation is loading. Please wait.

Presentation is loading. Please wait.

Good Programming Practices rules every programmer should know and follow.

Similar presentations


Presentation on theme: "Good Programming Practices rules every programmer should know and follow."— Presentation transcript:

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 it’s 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: 1.A description of what the procedure does 2.Type of arguments -> type of return value 3.Constraints that need to be satisfied by arguments (requires clause) 4.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.


Download ppt "Good Programming Practices rules every programmer should know and follow."

Similar presentations


Ads by Google