The students individually program an assignment and then review each other's solution.
| Parameters: | |
|---|---|
| Duration: | 10–50 minutes |
| Participants: | 4–20 students |
| Instructors: | 1 teacher |
| Class: | PCs |
| Resources: | programming assignments |
| Prerequisites: | being able to code the solution |
- Read and evaluate code of other students.
- Understand the importance of writing readable code.
- Learn approaches and mistakes of other students.
- Prepare a programming assignment that different students will program differently (multiple approaches for functional decomposition, choice of the data structure, etc.). Example assignments include:
- Implement the Caesar cipher.
- Implement the evaluation of postfix notation.
- Implement drawing a pyramid with Turtle graphics.
- Explain the best practices for writing readable code. This includes style and specifics of the given programming language, such as PEP8 for Python or Google Style Guide for Java. It also includes general principles of programming, such as these.
- Let students program the assignment.
- When two students finish, they sit together to read and understand each other's code. Then, they compare and discuss which code is 'better' and why (better naming of the variables, better input sanitization, lower complexity, better readability, ...).
- After the discussion, the two students merge their codes to create one 'best' solution. Merge two pairs and repeat the previous step.
- [Optional] Repeat the previous step to merge two groups of four.
- The groups present their single solution and comment on why it is the best. They can also present their mistakes and how to avoid them for the future.
- It is better to introduce this activity when students are more familiar with the programming language.
- Make pairs in a way that weaker students are with those more able, who will explain their mistakes.
Jakub Žák, 2019