Link Search Menu Expand Document

Making the most of programming assignments

When doing a programming assignment during a course, it can be tempting to just try changing your code until you get a perfect score. And when you finally get that perfect score, it can be tempting to move on to the next assignment immediately. Although you might end up getting a 10 for many of the assignments you get during the course, doing this will not result in the best learning outcome, and you might experience problems when doing similar programming assignments on an exam. By using the tips on this page, you can benefit even more from the programming assignments.


Before you have a good solution

Learn by failing

If you have trouble coming up with a solution by yourself, avoid looking at the reference solution. You learn by failing, so as soon as you take a look at the answer, your learning process stops almost entirely. The same holds for looking up solutions to similar problems on the internet. You will not learn much from copying those.

Do not give up too quickly. Try to get as far as you can, and only then ask help from TAs.

Learn to interpret error messages

When something goes wrong, you usually get an error message that gives you a clue as to what the cause of the issue is. Carefully read those error messages so you arrive at the right solution quickly. The more you do this, the quicker you will get at interpreting error messages. This will certainly come in useful if you encounter error messages during an exam.

Have a systematic way to solve problems

It is good to have steps in mind that you will follow to solve a programming problem. Following these steps over and over will make it second nature, and will come in useful especially when you encounter difficult programming problems. See the article “A systematic way to solve programming problems” for a suggestion.

Divide and conquer

If the problem you are solving seems too big, divide the problem into smaller problems and solve those individually.


After you have found a good solution

Understand why it works

Do you really understand what your code does? Or did you just get a good result “by accident”?

Go through your code line by line and make sure you understand what each line does. What are the types of the variables that you use? What types of parameters do the functions/methods that you’re calling take? What do they return?

What is the state of the different variables? Create a diagram to keep track of the state. If you are using Python, use a tool like http://pythontutor.com/ to verify whether your analysis is correct.

Do the assignments multiple times

Sometimes you are able to come up with a solution, but only after having worked on the assignment for hours. On an exam, you usually only have something like 15 minutes to finish an assignment. You can gain more speed by doing the assignment again at a later time. If you are working on WebLab, press the Reset button and start over without looking at your old solution. Repeat this until you are confident that you can solve the assignment quickly.

Try solving it differently

Now that you have a good solution, take a step back and think of other ways to solve the same problem. Try a different solution and see whether it works like you expected. In this way, you will have multiple different ways at your disposal, which will be useful when you encounter new problems (such as on an exam).

The final thing you should do is to compare your solution to the reference solution. If it is different, why is that? Which solution is better, your solution or the reference solution? Why?