What do developers consider magic literals? ...
Type de document :
Compte-rendu et recension critique d'ouvrage
Titre :
What do developers consider magic literals? A smalltalk perspective
Auteur(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]
Titre de la revue :
Information and Software Technology
Éditeur :
Elsevier
Date de publication :
2022-09
ISSN :
0950-5849
Discipline(s) HAL :
Informatique [cs]/Langage de programmation [cs.PL]
Résumé en anglais : [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 ...
Lire la suite >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.Lire moins >
Lire la suite >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.Lire moins >
Langue :
Anglais
Vulgarisation :
Non
Collections :
Source :
Fichiers
- https://hal.inria.fr/hal-03679130/document
- Accès libre
- Accéder au document
- https://hal.inria.fr/hal-03679130/document
- Accès libre
- Accéder au document
- https://hal.inria.fr/hal-03679130/document
- Accès libre
- Accéder au document
- document
- Accès libre
- Accéder au document
- Anqu22a-infsof106942-MagicLiterals-Official.pdf
- Accès libre
- Accéder au document