←PPNM

Tips on programming and debugging; FAQ

Good coding style:
  1. The code is segmented into small methods/functions spanning no more than a screenful.
  2. The names of functions, structures.members, and variables are meaningful and self-describing.
  3. The logic of the code is easy to follow and easy to modify (by somebody else); only a small number of comments are needed in a good code.
  4. Defensive programming: #include<assert.h> and use assertions plentifully: you can easily disable all assertions by simply recompiling the code with -DNDEBUG c-flag:
    CFLAGS += -DNDEBUG
    
Reading
Making The Best Use of C
Exercises
  1. Problem "debug".
  2. The "big programming exercise":
    • Consider the last two digits of your studienummer as a two-digit decimal number from 00 to 99. Make the corresponding exercise from this list. If your number is larger than the number of exercises, continue counting from the first exercise.
    • The target of the exercise should be report.pdf (or simlar) with your report. The report should be prepared in LaTeX and should contain a short description of the problem; the way you have solved it; and a figure, prepared in gnuplot, to illustrate that the problem has been solved correctly.
    • make clean should correctly clean the project.
    • make clean; make should correctly rebuild the project.
    • The project must be built before submission.