What do developers consider magic literals? ...
Document type :
Compte-rendu et recension critique d'ouvrage
Title :
What do developers consider magic literals? A smalltalk perspective
Author(s) :
Anquetil, Nicolas [Auteur]
Analyses and Languages Constructs for Object-Oriented Application Evolution [RMOD]
Delplanque, Julien [Auteur]
Analyses and Languages Constructs for Object-Oriented Application Evolution [RMOD]
Ducasse, Stephane [Auteur]
Analyses and Languages Constructs for Object-Oriented Application Evolution [RMOD]
Zaitsev, Oleksandr [Auteur]
Analyses and Languages Constructs for Object-Oriented Application Evolution [RMOD]
Arolla
Fuhrman, Christopher [Auteur]
Ecole de Technologie Supérieure [Montréal] [ETS]
Guéhéneuc, Yann-Gael [Auteur]
Concordia University [Montreal]
Analyses and Languages Constructs for Object-Oriented Application Evolution [RMOD]
Delplanque, Julien [Auteur]
Analyses and Languages Constructs for Object-Oriented Application Evolution [RMOD]
Ducasse, Stephane [Auteur]
Analyses and Languages Constructs for Object-Oriented Application Evolution [RMOD]
Zaitsev, Oleksandr [Auteur]
Analyses and Languages Constructs for Object-Oriented Application Evolution [RMOD]
Arolla
Fuhrman, Christopher [Auteur]
Ecole de Technologie Supérieure [Montréal] [ETS]
Guéhéneuc, Yann-Gael [Auteur]
Concordia University [Montreal]
Journal title :
Information and Software Technology
Publisher :
Elsevier
Publication date :
2022-09
ISSN :
0950-5849
HAL domain(s) :
Informatique [cs]/Langage de programmation [cs.PL]
English abstract : [en]
Context: Literals are constant values (numbers, strings, etc.) used in the source code. Magic literals are such values used without an explicit explanation of their meaning. Such undocumented values may hinder sourcecode ...
Show more >Context: Literals are constant values (numbers, strings, etc.) used in the source code. Magic literals are such values used without an explicit explanation of their meaning. Such undocumented values may hinder sourcecode comprehension, negatively impacting maintenance. Relatively little literature can be found on the subject beyond the usual (and very old) recommendation of avoiding literals and preferring named constants. Yet, magic literals are still routinely found in source code. Objective: We studied literal values in source code to understand when they should be considered magic or not (i.e., acceptable). Methods: First, we perform a qualitative study of magic literals, to establish why and under which conditions they are considered harmful. We formalize hypotheses about the reasoning behind how literals are considered magic. Second, we perform a quantitative study on seven real systems ranging from small (a few classes) to large (thousands of classes). We report the literals' types (number, string, Boolean,. . .), their grammatical function (e.g., argument in a call, operand in an expression, value assigned,. . .), or the purpose of the code in which they appear (test methods, regular code). Third, we report on another study involving 26 programmers who analyzed about 24,000 literals, to understand which ones they consider magic. Finally, we evaluate the hypotheses defining specific conditions under which literals are acceptable. Results: We show that (1) literals still exist and are relatively frequent (found in close to 50% of the methods considered); (2) they are more frequent in test methods (in 80% of test methods); (3) to a large extent, they were considered acceptable (only 25% considered magic); and (4) the hypotheses concerning acceptable literals are valid to various degrees. Conclusion: We thus pave the way to future research on magic literals, for example, with tools that could help developers deciding if a literal is acceptable.Show less >
Show more >Context: Literals are constant values (numbers, strings, etc.) used in the source code. Magic literals are such values used without an explicit explanation of their meaning. Such undocumented values may hinder sourcecode comprehension, negatively impacting maintenance. Relatively little literature can be found on the subject beyond the usual (and very old) recommendation of avoiding literals and preferring named constants. Yet, magic literals are still routinely found in source code. Objective: We studied literal values in source code to understand when they should be considered magic or not (i.e., acceptable). Methods: First, we perform a qualitative study of magic literals, to establish why and under which conditions they are considered harmful. We formalize hypotheses about the reasoning behind how literals are considered magic. Second, we perform a quantitative study on seven real systems ranging from small (a few classes) to large (thousands of classes). We report the literals' types (number, string, Boolean,. . .), their grammatical function (e.g., argument in a call, operand in an expression, value assigned,. . .), or the purpose of the code in which they appear (test methods, regular code). Third, we report on another study involving 26 programmers who analyzed about 24,000 literals, to understand which ones they consider magic. Finally, we evaluate the hypotheses defining specific conditions under which literals are acceptable. Results: We show that (1) literals still exist and are relatively frequent (found in close to 50% of the methods considered); (2) they are more frequent in test methods (in 80% of test methods); (3) to a large extent, they were considered acceptable (only 25% considered magic); and (4) the hypotheses concerning acceptable literals are valid to various degrees. Conclusion: We thus pave the way to future research on magic literals, for example, with tools that could help developers deciding if a literal is acceptable.Show less >
Language :
Anglais
Popular science :
Non
Collections :
Source :
Files
- https://hal.inria.fr/hal-03679130/document
- Open access
- Access the document
- https://hal.inria.fr/hal-03679130/document
- Open access
- Access the document
- https://hal.inria.fr/hal-03679130/document
- Open access
- Access the document
- document
- Open access
- Access the document
- Anqu22a-infsof106942-MagicLiterals-Official.pdf
- Open access
- Access the document