
The Effect of Richer Visualizations on Code Comprehension Dimitar Asenov Otmar Hilliges Peter Muller¨ Dept. of Computer Science Dept. of Computer Science Dept. of Computer Science ETH Zurich ETH Zurich ETH Zurich [email protected] [email protected] [email protected] ABSTRACT complement other research on development environments we Researchers often introduce visual tools to programming en- pose the following research questions: vironments in order to facilitate program comprehension, re- RQ1: Do richer code visualizations affect the speed with duce navigation times, and help developers answer difficult which code features can be detected? questions. Syntax highlighting is the main visual lens through RQ2: Do richer code visualizations affect the ability to cor- which developers perceive their code, and yet its effects and rectly answer questions about code structure? the effects of richer code presentations on code comprehen- RQ3: Do visually enhanced code constructs impair the read- sion have not been evaluated systematically. We present a rig- ability of unenhanced ones? orous user study comparing mainstream syntax highlighting Understanding code structure is part of more complex pro- to two visually-enhanced presentations of code. Our results gramming activities that developers perform regularly. There- show that: (1) richer code visualizations reduce the time nec- fore, we asked 15 questions about code structure in a con- essary to answer questions about code features, and (2) con- trolled study with 33 developers and compared their per- trary to the subjective perception of developers, richer code formance when using traditional syntax highlighting to two visualizations do not lead to visual overload. Based on our richer code visualizations, which go beyond changing font results we outline practical recommendations for tool design- properties. The results strongly indicate that richer visual- ers. izations reduce response times on a wide range of questions about code structure and do not lead to visual overload, con- Author Keywords trary to developers’ feedback. syntax highlighting; programming; code editor; visual programming; code comprehension; user study ACM Classification Keywords RELATED WORK H.1.2. User/Machine Systems: Human factors; H.5.2. User Green and Petre [10, 11] show that the usability of notations Interfaces: Evaluation/methodology; D.2.3. Coding Tools varies with the programmer’s task, and neither textual nor vi- and Techniques: Program editors; D.2.3. Coding Tools and sual notations are generally superior. However, they analyze Techniques: Structured programming notations for distinct programming models, and do not com- pare different notations for a single programming language. INTRODUCTION Hendrix et al. [13] show that a control structure diagram of In order to help developers be more efficient, recent research the code, embedded in the indentation area to the left of the in programming environments [3,6, 14, 16, 18, 19] has ex- text, can improve comprehension. However, the code itself plored novel visualizations of code blocks and their relation- is presented as plain text without even syntax highlighting. ships, spatial navigation between code fragments, and aug- Feigenspan et al. [9] investigate a specific use of color show- menting code with visual hints and abstractions. However, ing that different backgrounds for the components of a soft- all of these enhancements leave the presentation of the ac- ware product line help to identify which component some tual code unchanged. Since source code is the core medium code belongs to. In the only study of syntax highlighting in which programmers work, improving its presentation is at that we are aware of, Hakala et al. [12] investigate users’ least as important as enhancing the rest of the programming performance using the default coloring scheme of the Vim environment. Yet, syntax highlighting has rarely been em- code editor, code without highlighting, and one other color- pirically evaluated, and to our knowledge no study compared ing scheme. Surprisingly, they found no overall difference be- different visual code presentations of the same source code. tween the three schemes. The surprising results and scarcity To investigate improvements to code presentation as a way to of such studies merit more empirical investigation. Recent work on programming environments [3,6,7, 14, 19] Permission to make digital or hard copies of all or part of this work for personal or shows that visual enhancements can be beneficial. However, classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation all of these tools still use standard syntax highlighting for pre- on the first page. Copyrights for components of this work owned by others than the senting code. Barista [15] and Envision [1,2] are research author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or prototypes of structured code editors that allow flexible visu- republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]. alization of code fragments. The effect of their code presen- CHI’16, May 07 – 12, 2016, San Jose, CA, USA tation has not been investigated before. For our study, we use Copyright is held by the owner/author(s). Publication rights licensed to ACM. ACM 978-1-4503-3362-7/16/05...$15.00 Envision, available as an open-source project. DOI: http://dx.doi.org/10.1145/2858036.2858372 c Dimitar Asenov, Otmar Hilliges, and Peter M¨uller2016. This is the authors' version of the work. It is posted here for your personal use. Not for redistribution. The definitive version was published in CHI'16, http://dx.doi.org/10.1145/2858036.2858372. tiny-legend tiny-legend java.lang java.lang Legend Legend A A x y str x y str method String foo B String foo B int int String int int String String foo(int x, int y, String str) { C C int prod ← x*y int prod = x*y; int prod ← x*y if (prod <= 0) if prod≤0 prod≤0 return str; return str D str E D else if (x>42) { F return String.valueOf(y); else if x>42 x>42 } return String.valueOf(y) String.valueOf(y) throw new Error("error"); G } H throw new Error("error") throw new Error("error") (a) v-low (Eclipse - default settings) (b) v-med (Envision - alternate settings) (c) v-high (Envision - default settings) Figure 1: A Java method rendered using three different levels of visual enhancements. v-low shows Eclipse using default settings. v-med shows a variant of the Envision structured editor with the following enhancements over v-low: (A) all lists use alternating white and gray background instead of commas; (B) the names of formal parameters appear above the types; (C) a dashed line separates the method body from its signature; (D) blocks are visually outlined instead of showing curly braces. v-high also shows a variant of Envision, with the following additional enhancements over v-med: (E) some constructs, like compound statements have a background color; (F) many (but not all) keywords are replaced with icons; (G) method and constructor calls have orange text; (H) some expressions have a specific background color. Conversy [4] proposed a framework based on the Semiology Id Question of Graphics (SoG) to model the visual perception of code. Q1 Does the method throw exceptions directly in its body using a SoG recognizes seven visual variables: shape, luminosity, throw statement? color, position, size, orientation, and linking marks. In our Q2 Are all local variables immediately initialized (assigned) as part work, increasing levels of visual variety correspond to more of their declaration? Q3 Is subtraction (-) used in an expression? Any use counts, for extensive use of these visual variables, which Conversy sug- example: a-b, -1, –i, x -= 3. gests can improve the performance of readers. Q4 Is the ’this’ identifier used in the method? Q5 Is there a local variable (not a method parameter) of type String? VISUALIZATIONS AND EVALUATION METHOD Q6 Is there an if statement with an else branch? Both else, and if To determine if enhanced code presentations can help devel- else count. opers to more quickly comprehend code, we conducted a con- Q7 Is the type of the second method parameter ’int’? Q8 Is there a loop nested inside another loop? trolled experiment with three different levels of visual variety Q9 Does the method have exactly 3 parameters? for code presentation: v-low corresponds to the default Java Q10 Is there a top-level loop (not nested inside any other statement) syntax highlighting in Eclipse, v-med adds additional visual that appears after some code containing an if-statement? The enhancements, and v-high further increases visual variety. if-statement may be nested. Both v-med and v-high are produced with the Envision code Q11 Does the method explicitly create new objects of any type, in- editor. Figure1 illustrates the most important differences be- cluding arrays or exceptions. tween the three levels. For each level, we took screenshots of Q12 Does the method catch any exceptions? Q13 Is there a loop that contains two or more method/constructor 298 methods from the open-source Java text editor jEdit. The calls? The calls can be anywhere inside the loop, including in methods were selected so that they are complex (have at least nested statements, or arguments. 2 parameters and 3 block statements) but still fit within one Q14 Are there multiple points from which the method can return (the 1920x1080 screen. All comments were removed and methods end of the body is usually one such point)? Throwing excep- tions does not count. with features not supported by Envision were filtered out.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages6 Page
-
File Size-