Prof. Norm Matloff: Help in Programming Courses
My TA and I always want you to develop your programming and other skills
as much as possible. Here are some guidelines to follow in order to
ensure that if you have a difficult bug you can resolve it and
improve your programming/debugging skills at the same time:
- The TA and I should be a last resort, not a first one. If
you don't spend enough time thrashing through challenging situations,
you will never become a good programmer. It truly is a case of
"no pain, no gain." Come to us only after you have gone through
this "thrashing about." We are happy to help you, but this first step is
crucial.
- Similarly, make serious use of a debugging tool, applying the
Principle of Confirmation: Step through the code line by line, checking
values of variables that you "know" are valid -- and likely you will
eventually hit one that is not valid after all. There is your clue as
to at least the locaton of the bug.
- Do NOT just send a screenshot. In many/most cases, it is useless
without context.
- Instead, run the Unix script command (on CSIF if you don't
have a Unix machine), which records your entire session in a file; send
us that file, not a screenshot. In that session, you should not only
run the program but also show the context, e.g. by running pwd,
printenv and so on.