Whilst most undergraduate students eventually produce functionally correct code, they often disregard their code style and overall quality when it is not graded. As reported by the literature, quality defects affect both code structure and code style, and these issues seem to persist even in later years. This paper reports on the potential of a low-cost intervention that directed CS2 students to revise and refactor their code, with a specific focus on code structure, by resorting to a range of online refactoring resources. A "refactor-your-working-solution'' assignment received 73 submissions by 47 students. For each cleaned solution, students were required to provide a one-page report documenting their improvements step-by-step, and include a short reflection on their learning. Their efforts to clean code and their reflections are analysed in this experience report. Most students were able to apply multiple refactoring steps as well as other editing steps to improve their code style. In particular, we have identified a wide range of code smells in their code, hence gaining insights on their success in locating and removing 90% of them. Additionally, students' reflections appear to indicate an increased awareness as to the importance of readability and the need to develop more consistent habits when planning, coding and documenting their software.

Asking Students to Refactor their Code: A Simple and Valuable Exercise

Mirolo C.
2024-01-01

Abstract

Whilst most undergraduate students eventually produce functionally correct code, they often disregard their code style and overall quality when it is not graded. As reported by the literature, quality defects affect both code structure and code style, and these issues seem to persist even in later years. This paper reports on the potential of a low-cost intervention that directed CS2 students to revise and refactor their code, with a specific focus on code structure, by resorting to a range of online refactoring resources. A "refactor-your-working-solution'' assignment received 73 submissions by 47 students. For each cleaned solution, students were required to provide a one-page report documenting their improvements step-by-step, and include a short reflection on their learning. Their efforts to clean code and their reflections are analysed in this experience report. Most students were able to apply multiple refactoring steps as well as other editing steps to improve their code style. In particular, we have identified a wide range of code smells in their code, hence gaining insights on their success in locating and removing 90% of them. Additionally, students' reflections appear to indicate an increased awareness as to the importance of readability and the need to develop more consistent habits when planning, coding and documenting their software.
File in questo prodotto:
Non ci sono file associati a questo prodotto.

I documenti in IRIS sono protetti da copyright e tutti i diritti sono riservati, salvo diversa indicazione.

Utilizza questo identificativo per citare o creare un link a questo documento: https://hdl.handle.net/11390/1280600
Citazioni
  • ???jsp.display-item.citation.pmc??? ND
  • Scopus 0
  • ???jsp.display-item.citation.isi??? ND
social impact