Teaching with the Dojo in the Programming class: an assistant's point of view
Posted 06-08-2024 00:00:00 by Orestis Malaspinas ‐ 4 min read
This blog post will give a review on the different observations made while using the Dojo to teach in the C programming class.
Foreword
In this post we will talk about the experience of a teaching assistant who used the Dojo to write a programming assignment in the C programming class in HEPIA. The class is given during the first year in the computer science program.
Parti d'un template d'assignment existant.
There are no pre-requisites to follow this class. In particular students have no top limited C knowledge, to make
, to git
, and to the Linux command line. Most of them were not familiar with Linux prior to this class where they were made to install a dual boot with Linux on their laptop machines.
Use case
The assignment was created for a specific exercise about quadtrees used in the context of storing grayscale images. It consisted of writing the assignment, as well as unit tests, and a solution.
The assignment was based on an existing assignment given in the previous years at HEPIA.
Writing the assignment is relatively straightforward because of the structure following unit tests. After writing generalities about quadtrees and image processing, it was easy to follow the structure of the unit tests written for other assignments.
The workflow was the following: starting from the solution of the assignment one writes the unit tests, such that all the major functionalities and possible errors are tested. It is not possible nor necessary to be completely exhaustive when writing the tests because it would become a huge work for the students to account for any possible error. This is true in particular in C where not only one has to account for algorithmic or logic errors but also for a wide variety of memory or undefined behavior kind of errors.
By starting with the solution one can verify that the unit tests are correct wince it is very easy to write wrong unit tests that would really annoy the students. Also by following this approach it is relatively straightforward to write tests with increasing complexity. One particularly hard part was to decide when to leave the students more freedom on the way functionalities had to be implemented. While it is probably reassuring to have a very constraining structure, it removes part of the creative process to write complex algorithms.
Another difficulty was that tests tend to be interdependent. For example in C, allocation and deallocation of resources is manual and must be performed in every unit test, but typically the deallocation of resources is usually left by students to be performed at the end of the assignment because it is seen as a less interesting / important part of the assignment. This leads to extra memory errors that may pop up during the run of unit tests and can be misleading for the students.
The choice of the unit test framework also may lead to difficulties. The choice was made to use googletest, a framework written in C++ which introduces a mix of pure C and C++ in the unit test code and may not be ideal for the students. Also usually test frameworks tend to capture the environment and make the debugging a bit less straightforward an in standard code for inexperienced developers.
A very annoying feature of the test framework is when testing values inside a loop. By default a test report each error in the loop each time it is performed. This can lead to hundreds of errors and therefore make the output non readable. There are two possible ways to deal with this behavior. Either configure the tests such as all the other tests are skipped once one fails (the tests exit) but this is considered a bad practice, either manually add a condition to exist the test function when a test failed in the loop. The latter was the choice that was made in this assignment.
The documentation about the correction of the assignment was lacking. It was not clear how to proceed to publish a correction and it must be clarified that:
- One first create an exercise,
- Solve the exercise,
- Publish the exercise as a solution.
Finally the students had two main critics when performing the assignment. The errors produced by the unit tests and the memory errors may be difficult to read (sanitizers in particular produce "ugly" errors). The report on the tests should be revamped to be clearer and summarize better the errors performed.