![]() |
School of Engineering and Applied
Science
Department of Computer Science CSci 133 -- Introduction to Software Development http://www.seas.gwu.edu/~csci133/spring03 Prof. Michael B. Feldman mfeldman@gwu.edu |
Work on Project 4; concentrate on the insertInOrder method.
A problem in developing and debugging collection classes is knowing whether the methods are handling the collection correctly. Since the data is private, the client program really can't do much to view the internals of the data.
Here is a technique used in industry for debugging: in your list class, declare a private static boolean variable debugging. When you are testing, set this variable to true; after your testing is done and you are just using the class, set it to false and recompile.
Then, in each of the methods, include a statement like
if (debugging)
{
// display contents of the data structures (maybe call toString
to do this)
}
This will display your data structures if and only if the flag is true; otherwise, it will do nothing. Try it; see if the idea works for you.
(end of lab)