Improving Readability of Scratch Programs with Search-based Refactoring

Felix Adler, Gordon Fraser, Eva Gründinger, Nina Körber, Simon Labrenz +3 more
8/16/2021
cs.SE

Official code: se2p/artifact-scam2021 (1 star, Jupyter Notebook, last commit 2021-08-20).

Abstract

Block-based programming languages like Scratch have become increasingly popular as introductory languages for novices. These languages are intended to be used with a "tinkering" approach which allows learners and teachers to quickly assemble working programs and games, but this often leads to low code quality.

Show full abstract

Such code can be hard to comprehend, changing it is error-prone, and learners may struggle and lose interest. The general solution to improve code quality is to refactor the code. However, Scratch lacks many of the common abstraction mechanisms used when refactoring programs written in higher programming languages. In order to improve Scratch code, we therefore propose a set of atomic code transformations to optimise readability by (1) rewriting control structures and (2) simplifying scripts using the inherently concurrent nature of Scratch programs. By automating these transformations it is possible to explore the space of possible variations of Scratch programs. In this paper, we describe a multi-objective search-based approach that determines sequences of code transformations which improve the readability of a given Scratch program and therefore form refactorings. Evaluation on a random sample of 1000 Scratch programs demonstrates that the generated refactorings reduce complexity and entropy in 70.4% of the cases, and 354 projects are improved in at least one metric without making any other metric worse. The refactored programs can help both novices and their teachers to improve their code.

View on arXivView PDF

Code Implementations(1)

10Jupyter Notebook, JavaScriptAug 13, 20215 years ago

Similar Papers

Cite this paper

@article{adler2021improving,
  title  = {Improving Readability of Scratch Programs with Search-based Refactoring},
  author = {Felix Adler and Gordon Fraser and Eva Gründinger and Nina Körber and Simon Labrenz and Jonas Lerchenberger and Stephan Lukasczyk and Sebastian Schweikl},
  year   = {2021},
  eprint = {2108.07114},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2108.07114}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2108.07114.svg)](https://codeofpaper.com/paper/2108.07114)

Discussion