Is “notDone” the Same As “!done”? The Effect of Different Ways for Expressing Negation
Negation has been studied extensively in the fields of linguistics, psychology, and logic. However, it has been almost entirely overlooked in the realm of code comprehension research and the teaching of programming. Negations in code are interesting for several reasons. First, negations can be expressed either using logic operators (like ! or !=) or else by words embedded in variable names (as in notDone). Second, different types of negations can be combined together in the same expression. To explore whether using different negative expressions affects code comprehension, we conducted a controlled experiment involving 268 participants. The task was to understand short code snippets containing various logical expressions and types of negations. The results showed significant differences between the comprehension of different code snippets, both in terms of time needed and in terms of the correctness achieved. This illustrates a cognitive complexity that has important implications for writing more readable code and for guiding refactoring practices. In particular, we suggest that students be taught to avoid negations if possible, e.g. by using len > 0 rather than len != 0 to verify that an array is not empty.
Tue 5 AugDisplayed time zone: Eastern Time (US & Canada) change
09:15 - 10:30 | E: (Mis)conceptions in programmingResearch Papers at Grove Ballroom I+II Chair(s): Craig Zilles University of Illinois at Urbana-Champaign | ||
09:15 25mTalk | Misconceptions in Programming: Intuitive Reasoning and Tracing Task Performance Across Experience Levels Research Papers | ||
09:40 25mTalk | Is “notDone” the Same As “!done”? The Effect of Different Ways for Expressing Negation Research Papers | ||
10:05 25mTalk | Surveying Upper-Secondary Teachers on Programming Misconceptions Research Papers Link to publication DOI |