DOI: 10.5281/zenodo.5818034
title: What Do Developers Consider Magic literals? A Smalltalk Perspective

description: Data for the paper: "What Do Developers Consider Magic literals? -- A Smalltalk Perspective" The file 'allLiteralData.csv' contains a classification of cerca 24K literals performed by 26 different participants (P1 to P26). <strong>Data</strong> Columns are: literal -- the value of the literal (eg: "1") kind -- the type among: <em>Integer</em>, <em>String</em>, <em>Symbol</em>, <em>Boolean</em>, <em>Array</em>, <em>UndefinedObject</em> (=nil), <em>Float</em>, and <em>Character</em> astNode -- the AST Role of the literal among: <em>Argument</em> (of a message), <em>Operand</em> (of an operation), argument of a <em>Pragma</em>, value <em>Returned</em>, value <em>Assigned</em> to a variable, <em>Receiver</em> of a message, member of a <em>Sequence</em> (ie more or less an expressionStatement with the literal as expression), member of an <em>array</em>. specialArg -- whether the literal appears in one of the specific context that are linked to language conventions: "<em>loopFrom1</em>" (literal "1" is start of a loop), "<em>increment1</em>" (literal "1" used as increment or decrement), "<em>streamOutput</em>" (string or character literal output on a stream), "<em>nameArg</em>" (string literal argument of a "name:" message), "<em>other</em>" (none of the previous cases) status -- whether the literal was classified "<em>Magic</em>", "<em>NotMagic</em>" (acceptable), or "<em>Undecided</em>" idInMethod -- the position of the literal in the list of all literals that its parent method contains (whether it is the 1st, 2nd, ... of its parent method). Will always be &gt;=1 and &lt;= "<em>nbLiteralsInMethod</em>" (see below) isConstantMethod -- whether the parent method of the literal only returns it (which is the convention in Pharo to implement constant) method -- name of the class and method containing the literal specialMethod - whether the parent method is a "<em>test</em>" method, an "<em>example</em>" method, or a "regular" method (ie not <em>test</em> nor <em>example</em>) commentLength -- length (in character) of possible comments in the parent method nbLiteralsInMethod -- total number of literal in the parent method (related to "<em>idInMethod</em>") project -- name of the system where the literal was found, among: <em>Morphic</em>, <em>Parser</em>, <em>Pharo</em>, <em>Polymath</em>, <em>Roassal</em>, <em>Seaside</em>, and <em>VMMaker</em>. expId -- batch number in the project where that literal was classified by a participant ("<em>expert</em>"). expert -- code of the participant that classified the literal expertise -- self declared participant's knowledge of the system. One of: "<em>low</em>", "<em>medium</em>", or "<em>high</em>" <strong>Keys</strong> The tuple (<em>idInMethod</em>, <em>method</em>) uniquely identifies a literal. The tuple (<em>project</em>, <em>expId</em>) uniquely identifies a batch of 50 literals classified by a participant. A batch contains 50 literals and the same literal may appear in different batches (intended redundancy). <strong>Heuristic validation</strong> The various hypotheses formulated in the paper are validated following the rules below: <em>Heuristic 1 </em>(impact of participant expertise) -- counts all literals Magic or not ("<em>status</em>" column) for each value of column "<em>expertise</em>" <em>Heuristic 2</em> (self describing literals) -- for all self describing literals, count number of "<em>status</em>"= "<em>Magic</em>" or not. Self describing literals are: booleans, "type" = "Boolean" empty pointer, "type" = "UndefinedObject" empty arrays, "type" = "Array" and "literal" = "#()" or "literal" = "{}" strings, "type" = "String" symbols "type" = "Symbol" <em>Heuristic 3 </em>(coding convention) -- for all literals in specified contexts ("<em>specialArg</em>" != "<em>other</em>"), count number of "<em>status</em>"= "<em>Magic</em>" or not. <em>Heuristic 4</em> (assigned to a variable/returned by a method) -- for all literals directly assigned to a variable ("<em>astNode</em>" = "<em>assign</em>.") or directly returned by a method ("<em>astNode</em>" = "<em>return</em>"), count number of "<em>status</em>"= "<em>Magic</em>" or not. <em>Heuristic 5</em> (pragma argument) -- for all literals argument of a pragma ("<em>astNode</em>" = "<em>pragma</em>"), count number of "<em>status</em>"= "<em>Magic</em>" or not. <em>Heuristic 6 </em>(in Test or Example method) -- for all literals in a test method ("<em>specialMethod</em>" = "<em>test</em>") or example method ("<em>specialMethod</em>" = "<em>example</em>"), count number of "<em>status</em>"= "<em>Magic</em>" or not.