68 Smells in Block-Based Programming Languages Felienne Hermans Delft University of Technology Delft, the Netherlands f.f.j.hermans@tudelft.nl Kathryn T. Stolee North Carolina State University Raleigh, NC, USA ktstolee@ncsu.edu David Hoepelman Delft University of Technology Delft, the Netherlands D.J.Hoepelman@student.tudelft.nl Abstract—Code smells were originally designed for object- oriented code, but in recent years, have been applied to end- user languages, including spreadsheets and Yahoo! Pipes. In this paper, we explore code smells in block-based end-user programming languages aimed at education. Specifically, we explore the occurrence of smells in two educational languages not previously targeted by smell detection and refactoring research: LEGO MINDSTORMS EV3 and Microsoft’s Kodu. The results of this exploration show that object-oriented-inspired smells indeed occur in educational end-user languages and are present in 88% and 93% of the EV3 and Kodu programs, respectively. Most commonly we find that programs are plagued with lazy class, duplication, and dead code smells, with duplication smells being present in nearly two-thirds of programs in both languages. I. I NTRODUCTION End-user programmers are said to outnumber professional programmers three times over [1]. In their jobs, they face many of the challenges of professional developers, such as identifying faults, debugging, or understanding code written by someone else [2]. Similar to professional development is the longevity of the produced artifacts; the average lifespan of a corporate spreadsheet, for example, is five years [3]. During this long lifespan, end-user artifacts are modified, often by different people. These properties make them, like source code artifacts, vulnerable to smells. Code smells are deficiencies or anti-patterns in source code. As outlined in the taxonomy of Fowler [4], smells pertained to object-oriented (OO) code. These OO professional program- ming languages were the focus for at least the first decade of code smell and refactoring research [5]. Recently, however, smells in end-user programming have also received attention in research, most notable structural smells in Yahoo! Pipes web mashups [6] and Excel spreadsheets [7]. Experiments in these and other end-user areas have shown that end-user programmers understand smells, and often prefer versions of their code that are non-smelly [8]–[10]. In this paper we broaden research on end-user code smells by examining block-based educational programming lan- guages. Smells are particularly interesting in educational lan- guages as the programs are often shared and remixed through online communities (e.g., Scratch, LEGO MINDSTORMS EV3, and Microsoft’s Kodu all have online repositories for sharing). The presence of smells implies an opportunity for refactoring research to improve the quality of these programs and is especially important for shared programs. To investigate the occurrence of smells in educational pro- grams, we have gathered 44 programs written by children and online community members in two languages, EV3 and Kodu, and studied the occurrences of code smells. The results of this evaluation show that OO-inspired smells in fact occur in both end-user education languages: 88% of the EV3 and 93% of the Kodu programs contained at least one smell. In EV3 and Kodu, the smells that we most commonly find are small abstractions (lazy class), duplication, and dead code, illustrating commonality across all end-user programming domains. The contributions of this work are as follows: Definitions for 11 end-user programming smells in LEGO MINDSTORMS EV3 and Kodu (Section III) Two case studies investigating end-user smells in educa- tional programming languages: LEGO MINDSTORMS EV3 and Kodu (Section IV and Section V) II. BACKGROUND In this work, we use smells previously explored in end-user programming languages to guide our exploration and analysis of programs written in the block-based educational languages. In previous research, code smells were applied to various other, end-user programming paradigms. Most prominently, research has focused on Yahoo! Pipes, a web mashup language and environment, and spreadsheets. Between those two domains, we observe few similarities in the code smells studied. Of the 11 smells covered between the two languages, only the duplicate code, lazy class, and long method smells were studied in both, illustrating the breadth of possible code smells, even in smaller, end-user languages. Many languages have been developed with computer sci- ence education in mind, such as Scratch [11], Alice [12], Kodu [13], LEGO MINDSTORMS EV3 [14]. Each of these languages has its own unique structures, abstractions, and programming environment. One advantage of block-based languages, from the user’s perspective, is that syntax errors are often prevented, allowing the user to concentrate on program design and logic. In this work, we focus on EV3 and Kodu, two popular block-based educational languages with public repositories for sharing programs, with which the authors have prior experience. LEGO MINDSTORMS EV3: EV3 is the third iteration of the LEGO MINDSTORMS robotics line. It consists of several sensors, four motors and an ARM 9 “intelligent brick”. The robotics kit comes with a control software package, which 978-1-5090-0252-8/16/$31.00 c 2016 IEEE