Software development hint: packaging main programs as subroutines

Bugs in new subroutines frequently have nothing to do with the routine itself, but with the calling of the routine through the subroutine interface. To reduce the complexity of such debugging, often it is useful to first write the subroutine as a main program to get it up and running and debugged. Then, once you know for sure that the code works, cut the relevant parts from the main program and paste them to the subroutine and make sure that you produce exactly the same results. In the first phase, you can be sure that there are no subroutine interface bugs and, in the second phase, you can be sure that there are no actual bugs in the routine. Reducing the possible phase space of bugs always speeds the debugging process, often exponentially.

This is precisely what we have done with ``quicksch.c'' in the last assignment. This way, most of this problem involves just repackaging ``quicksch.c'' as schint().

Tomas Arias 2007-02-16