Presentation on theme: "Good Programming Practices rules every programmer should know and follow."— Presentation transcript:
Good Programming Practices rules every programmer should know and follow.
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
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.
Documenting a procedure Example:
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
Documenting an ADT Example:
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
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.