Source-linked AI summary

Leveraging Game-Based Platform to Teach Code Refactoring: An Experience with Refactoria

Eman Abdullah AlOmar, Christopher Engelbart, Stephen Pachucki, Nerissa Lundquist, David Van Hist

arXiv:2609.40086v1cs.SE

TL;DR

Identifying and refactoring code smells requires training and experience, while lack of motivation may hinder adoption of refactoring tools. This paper presents Refactoria, a game-based learning environment in which students refactor code through puzzles. After completing the game, 83% of participants responded positively when asked how their understanding of refactoring had changed.

  • Problem

    Identifying and refactoring code smells requires training and experience, and lack of motivation may hinder developers’ adoption of refactoring tools.

    Source: §1 · p. 1
  • Method

    Refactoria teaches basic refactoring concepts through a game in which players improve flawed code while preserving its test cases.

    Source: §1 · p. 2, §7 · p. 6
  • Results

    83% of participants responded positively to the open-ended question about how their understanding of refactoring changed after completing the game.

    Source: §5 · p. 4
  • Takeaways & Limitations

    The game gives students first-hand practice with hard-to-read code and its easier-to-read equivalent, which the authors expect to help them recognize and fix such code.

    Source: §6 · p. 6

    A few players focused on game constraints rather than maintainability, indicating some misalignment between the game mechanics and learning objectives.

    Source: §6 · p. 6

Abstract

from arXiv · show

Refactoring is the art of improving the internal structure of the code without altering its external behavior. Because of the topic's significance, several teaching methods and strategies have been proposed in the literature. However, skills in identifying and refac- toring code smells come from training and experience, and a lack of motivation may hinder developers' adoption of refactoring tools. In this paper, we discuss the results of an experiment in the classroom that involved performing various refactoring activities to remove antipatterns using Refactoria, an innovative game-based tool that supports the acquisition of code smell and refactoring concepts. The players play as an expert chef with their sidekick Watson the Whiskbot to refactor Watson's instructions into efficient, readable, and easily maintainable code. We present an experiment with 30 student developers. In particular, we study the perception, effectiveness, and usefulness of gamification for engaging developers in code smell identification and refactoring. Our evaluation indicates a high perceived usefulness among students, and participants reported that Refactoria facilitated their understanding of the refactoring concepts.

1 Introduction

Refactoring can improve software quality, but identifying and resolving code smells requires training and experience, and lack of motivation can hinder adoption of refactoring tools. Refactoria uses a game-based code-editing environment to teach these skills.

1 Introduction

  • Refactoring is a critical maintenance activity, and code smells are software characteristics that may indicate problems affecting quality.Effective refactoring improves quality without changing external behavior; the skills to identify and refactor code smells develop through training and experience.Source: §1 · p. 1
  • Refactoring skills receive limited attention in some computing courses, while developers may lack exposure or motivation to adopt refactoring tools.The paper notes that design-level antipatterns can be challenging to resolve, including in well-engineered projects.Source: §1 · pp. 1–2
  • Refactoria applies gamification to teach basic refactoring concepts through a game-based learning environment.Players improve flawed code, with the intended goal of reapplying lessons in external situations.Source: §1 · p. 2
  • Across thirteen levels, players identify code smells and apply refactoring techniques while keeping all test cases passing.The game reveals the names of discovered smells and techniques and adds them to a reference dictionary.Source: §1 · p. 2

2 Background and Related Work

Prior work has taught refactoring through digital and non-digital games, quizzes, code-based tasks, and other approaches. Refactoria distinguishes itself by making work on a full software system central to play.

2 Background and Related Work

  • CleanGame teaches identification of five code smells through quizzes and code-identification questions; its participants identified twice as many smells with gamification as without it.Other cited approaches include a refactoring scenario, a multiplayer card game, and a gamification system that tracks refactorings.Source: §2 · p. 2
  • Related games include a Minecraft-based code-issue game, a real-world-code game design, Refactor4Green, and RefGame.The cited studies report positive feedback or educational outcomes for some of these approaches.Source: §2 · p. 2
  • Unlike approaches centered on snippets or quizzes, Refactoria engages students in refactoring a full software system, with code editing and execution integrated into the game.Its Java-like custom language and in-game execution environment let players run code without leaving the game.Source: §2 · p. 2

3 Refactoria Overview

Refactoria frames refactoring as improving the legacy code of a restaurant’s previous owner. Its narrative provides context and hints for the level puzzles.

3 Refactoria Overview

  • The story presents Watson’s code as a legacy from a previous restaurant owner, echoing the task of updating software written by someone else.The narrative is intended to keep players engaged while establishing a reason to improve the code.Source: §3 · p. 3
  • Narrative passages include hints for solving level puzzles, such as the “Speculative Generality” level’s unused squash-soup recipe.Figure 1 is identified as an example of the first level.Source: §3 · p. 3
  • Figure 1 is the “Welcome to Refactoria” puzzle.The passage identifies it as an example of the first level.Source: Figure 1 · p. 3, §3 · p. 3

4 Experimental Setup and Execution

The study evaluates students’ perceived usefulness of Refactoria in an undergraduate object-oriented programming course. Thirty students completed a game-based assignment and survey, whose responses were reviewed by the authors.

4.1 Goal and Research Question

  • The study’s goal was to evaluate Refactoria’s acceptance and usefulness, with perceived usefulness as its research question.Source: §4.1 · p. 3

4.2 Course Overview

  • The setting was an undergraduate object-oriented programming course with two weekly lectures and hands-on assignments.Course deliverables included six individual homework assignments, fourteen quizzes, and thirteen labs.Source: §4.2 · p. 3

4.3 Teaching Context and Participants

  • Thirty students at Stevens Institute of Technology completed the assignment after prior instruction in code smells and refactoring.Participants reported one to three years of programming experience and one to two years of Java experience; the assignment counted for 5% of the final grade.Source: §4.3 · p. 3

4.4 Study Execution

  • Students played through levels, identified code smells, applied refactoring under constraints, and checked that behavior and functionality were preserved.Source: §4.4 · p. 3

4.5 Survey Design

  • The 36-question survey covered participant background, puzzle experience, learning, challenges, and intended future use of refactoring.It combined open-ended and multiple-choice questions; 24 participants provided informed consent.Source: §4.5 · p. 3

4.6 Data Analysis

  • Two authors reviewed the survey results independently, then discussed them to reach consensus.One author performed the initial data extraction and analysis, which the other reviewed and analyzed.Source: §4.6 · p. 3

5 Results

Students reported improved understanding of refactoring and greater confidence applying it after playing Refactoria. They also rated its Java-like logic as relevant to real refactoring, while puzzle completion varied by level.

5 Results

  • 50% felt fully confident refactoring after playing, 43% somewhat confident, and 7% not very confident.The responses were from 24 participants.Source: Figure 3 · p. 4, §5 · p. 4
  • 95% were already familiar with refactoring, and 85% said the game’s principles applied to object-oriented languages such as Java.The authors present the subsequent confidence and skill findings as reflecting a bridge from theoretical knowledge to practical application.Source: §5 · pp. 4–6
  • The Java-like refactoring logic received a mean mirroring score of 3.55 and a median of 4.0 on a 1–5 scale.More than half rated its match to their Java refactoring decisions as 4 or 5; neutral and lower ratings suggest some gameplay abstractions differed from IDE workflows.Source: Figure 4 · p. 4, §5 · p. 4
  • 83% of participants responded positively that their understanding of refactoring changed after the game.Six said it let them practice refactoring concepts, and four said they learned new concepts.Source: §5 · p. 4
  • Four puzzles had 100% completion, while “An Industrial Kitchen” had the lowest rate, 59%; completion declined steadily without difficulty spikes.Other reported rates ranged from 71% to 94%.Source: Figure 6 · p. 5, §5 · p. 5
  • 50% mentioned making code more efficient or less repetitive; Extracting was the technique participants most often named as one they felt confident applying (41.8%).Moving was named by 32.7% and Renaming by 25.5%; 77.5% reported no challenge understanding why refactoring was necessary.Source: §5 · p. 5

6 Reflection

Refactoria’s puzzles and test constraints support hands-on refactoring practice, while the reflection identifies learner-fit and accessibility gaps and proposes improvements.

6 Reflection

  • Instructors should use Refactoria as a complement to traditional teaching, with test-preserving constraints and automated feedback to support reasoning about refactoring.The authors also suggest comparing code-quality metrics before and after play to assess learning outcomes.Source: §6 · p. 6
  • Trial-and-error puzzles progressively introduce code smells, and test cases reinforce behavior preservation as students report a sense of accomplishment.The authors attribute students’ success to their own skills.Source: §6 · p. 6
  • Working through unfamiliar existing code mirrors a common real-world task, while deliberately hard-to-read starting code gives practice recognizing and improving readability.The authors expect this practice to help students recognize and fix hard-to-read code in the future.Source: §6 · p. 6
  • The custom language made learning independent of prior experience with a specific language, but some players prioritized game constraints over maintainability.Some students already familiar with refactoring reported that the game gave them practice rather than new techniques.Source: §6 · p. 6
  • Future versions should add reflection prompts and hints; accessibility was not considered, and screen-reader or voice-control support would require intensive interoperability work.The authors also suggest customizable editor themes and dyslexia-friendly fonts.Source: §6 · p. 6

7 Conclusion

Refactoria is a 13-level gamified tool that teaches basic concepts of code smells and refactoring through code-based puzzles. In a user study, participants found the game helpful for learning refactoring.

7 Conclusion

  • Refactoria is an interactive gamified tool that teaches basic code-smell and refactoring concepts through 13 code-based puzzles.The puzzles begin with code that passes tests but contains code smells; players refactor it to satisfy additional requirements intended to teach better coding practices.Source: §7 · p. 6
Loading 2609.40086v1…