1 Introduction
-
dead methods affect open-source Java desktop applications;
-
dead methods generally survive for a long time, in terms of commits, before being “buried” (i.e., removed) or “revived” (i.e., used);
-
dead methods that are then revived tend to survive less, as compared to dead methods that are then buried;
-
dead methods are rarely revived;
-
the majority of dead methods are dead since their creation.
-
We add ten open-source Java desktop applications to our past dataset. The data analyses now take into account the commit histories of 23 Java desktop applications with software project hosted on GitHub. This makes the study presented in this paper the largest one on dead code in terms of studied software applications.
-
We extend the presentation and discussion of the results in light of the new data. We also highlight whether, or not, there are different patterns when passing from the old dataset (comprising 13 software applications) to the new dataset (comprising 23 software applications).
-
We provide further analyses.
-
We update the discussion on the related work.
2 Background and Related Work
2.1 Dead Code Detection
2.1.1 Dynamic Code Analysis
2.1.2 Static Code Analysis
run()
methods of threads, initializes, etc.). After identifying alive methods, DCF marks those methods that are not alive as dead. To assess the validity of DCF, as well as the underlying approach, Romano and Scanniello compared DCF with JTombstone, CodePro AnalytiX, and DUM-Tool. The results of this comparison indicated that DCF outperformed the other tools in terms of: correctness of detected dead methods (average precision equal to 84%) and accuracy of detected dead methods (average f-measure equal to 85%). As for completeness (average recall equal to 87%) in detecting dead methods, DCF was comparable to DUM-Tool.2.1.3 Refactoring vs. Optimization Perspective
2.2 Empirical Studies on Dead Code
3 Study Design
3.1 Research Questions
-
This RQ aims to understand whether open-source Java desktop applications are affected by dead methods. We can postulate that the higher the spread of dead methods in a Java desktop application, the higher the likelihood for a developer to bump into dead methods during source code maintenance and evolution tasks. Since dead code harms both source code comprehensibility and maintainability (Romano et al. 2016; 2020), the negative impact of dead methods on both source code comprehensibility and maintainability would be amplified.
-
Romano et al. (2020) found, as highlighted in Section 2, that developers can consciously introduce or leave dead code in a software application because they think to use it later. If a dead method has a long lifespan, its future use should be less likely. This is because that dead code is not updated during the evolution of a software application—i.e., dead code was written at a time when the software application was different (Martin 2008).
-
The study of this RQ allows us to understand if developers remove dead methods from source code. We can postulate that if developers do not remove dead methods from source code, they are unaware of their presence or they believe that dead methods are not harmful (Romano et al. 2020). Our study is purely quantitative and, therefore, we are not able to discern between these two scenarios. Nevertheless, the study of RQ3 can provide useful indications on whether developers take care of dead code. In other words, the results from RQ3 can support the qualitative findings of the interview study by Romano et al. (2020), so further contributing to the body of knowledge on dead code.
-
Based on the findings by Romano et al. (2020), developers can consciously introduce or leave dead code in the source code, because they think to use it later. We formulated this RQ to understand whether developers actually use dead methods in the future. In other words, if the introduction of dead code can be intended as a means for future re/use of source code.
-
With this RQ, we want to focus our attention on the introduction of dead methods in the source code. Understanding when this code smell is introduced in a given software application could help us to delineate/define a better counteraction to deal with this smell. For example, if dead methods are mostly introduced when the corresponding methods are created, then just-in-time dead-method detection tools are more advisable. Such a kind of tools should continuously monitor developers while coding and possibly warn them if they create a method that is dead.
3.2 Study Context and Planning
Application | # Stars | Last Analyzed | Lifespan | # Methods∗ | # Classes∗ |
---|---|---|---|---|---|
Commit | |||||
4HWC Autonomous Car | 1 | 5a5c472 | 102 | 137 | 37 |
8_TheWeather | 1 | f6abd54 | 38 | 346 | 37 |
BankApplication | 72 | 6856256 | 102 | 537 | 121 |
bitbox | 1 | af2af8b | 15 | 548 | 64 |
Density Converter | 225 | e70dcad | 162 | 384 | 71 |
Deobfuscator-GUI | 112 | deb003e | 29 | 221 | 47 |
graphics-tablet | 0 | 8a3df4c | 35 | 697 | 81 |
JavaANPR | 125 | eff9acf | 256 | 786 | 92 |
javaman | 0 | 7a03c36 | 58 | 230 | 38 |
JDM | 0 | a435b4d | 25 | 82 | 16 |
JPass | 81 | c6b13af | 134 | 366 | 82 |
MBot | 0 | ff07dac | 21 | 56 | 16 |
SMV APP | 1 | 4c17370 | 67 | 408 | 96 |
Calculator | 9 | cfa2504 | 112 | 259 | 60 |
Desktop Weather Widget | 0 | ea1acf7 | 69 | 86 | 18 |
IOU | 1 | c4ca28c | 60 | 211 | 43 |
JavaAppBuilder | 0 | 3c942ca | 42 | 445 | 56 |
Metis Dictionary | 1 | c4ca28c | 25 | 363 | 35 |
mvn-gui | 0 | e3db771 | 40 | 274 | 61 |
PocketMine-GUI | 10 | e1538b4 | 45 | 290 | 48 |
SaveMyPass | 1 | 82bc309 | 31 | 507 | 98 |
SoccerQuizApp | 0 | 0a6ca87 | 46 | 92 | 17 |
Swing Chat | 2 | 02b64b2 | 73 | 113 | 21 |
3.3 Data Analyses
3.4 Data Availability
4 Results
4.1 RQ1. Are Dead Methods Spread in Open-source Java Desktop Applications?
4.2 RQ2. How Long Do Dead Methods Survive in Open-source Java Desktop Applications?
Application | # (Distinct) | # Events | KMMedSurvTime | |
---|---|---|---|---|
Dead Methods | ||||
4HWC Autonomous Car | 27 | 14 | 59 | [26, −] |
8_TheWeather | 87 | 1 | − | [−, −] |
BankApplication | 270 | 229 | 9 | [8, 13] |
bitbox | 210 | 15 | − | [−, −] |
Density Converter | 288 | 203 | 21 | [15, 24] |
Deobfuscator-GUI | 156 | 142 | 14 | [12, 17] |
graphics-tablet | 407 | 227 | 17 | [7, 18] |
JavaANPR | 237 | 164 | 5 | [5, 88] |
javaman | 142 | 97 | 18 | [9, 22] |
JDM | 17 | 16 | 3 | [3, 3] |
JPass | 77 | 28 | 83 | [60, −] |
MBot | 5 | 3 | 11 | [1, −] |
SMV APP | 183 | 151 | 11 | [7, 14] |
Calculator | 2 | 1 | 8 | [8, −] |
Desktop Weather Widget | 86 | 73 | 4 | [2, 7] |
IOU | 30 | 4 | − | [−, −] |
JavaAppBuilder | 369 | 228 | 6 | [4, 8] |
Metis Dictionary | 143 | 137 | 17 | [17, 17] |
mvn-gui | 76 | 16 | 26 | [24, −] |
PocketMine-GUI | 133 | 75 | 11 | [11, 13] |
SaveMyPass | 9 | 3 | − | [24, −] |
SoccerQuizApp | 60 | 44 | 3.5 | [2, 5] |
Swing Chat | 37 | 28 | 10 | [5, 28] |
Application | p-value | Cliff’s δ |
---|---|---|
4HWC Autonomous Car | 1 | − |
BankApplication | 0.217 | − |
bitbox | 0.159 | − |
Density Converter | 0.002 | 0.323 (small) |
Deobfuscator-GUI | 0 | 0.481 (large) |
graphics-tablet | 0.853 | − |
JavaANPR | 0.62 | − |
javaman | 0.088 | − |
JPass | 0.014 | 0.561 (large) |
SMV APP | 0.678 | − |
Desktop Weather Widget | 0 | 0.883 (large) |
JavaAppBuilder | 0 | 0.467 (medium) |
mvn-gui | 0.677 | − |
PocketMine-GUI | 0.483 | − |
SoccerQuizApp | 0.305 | − |
Swing Chat | 0.442 | − |
4.3 RQ3. Do Developers Bury Dead Methods in Open-source Java Desktop Applications?
Application | %RemovedDeadMethods | %RevivedDeadMethods | %CensoredDeadMethods |
---|---|---|---|
4HWC Autonomous Car | 48.148 | 3.704 | 48.148 |
8_TheWeather | 1.149 | 0 | 98.851 |
BankApplication | 63.333 | 21.481 | 15.185 |
bitbox | 3.81 | 3.333 | 92.857 |
Density Converter | 57.639 | 12.847 | 29.514 |
Deobfuscator-GUI | 62.821 | 28.205 | 8.974 |
graphics-tablet | 49.386 | 6.388 | 44.226 |
JavaANPR | 68.354 | 0.844 | 30.802 |
javaman | 41.549 | 26.761 | 31.69 |
JDM | 0 | 94.118 | 5.882 |
JPass | 22.078 | 14.286 | 63.636 |
MBot | 60 | 0 | 40 |
SMV APP | 16.94 | 65.574 | 17.486 |
Calculator | 50 | 0 | 50 |
Desktop Weather Widget | 36.047 | 51.163 | 12.791 |
IOU | 13.333 | 0 | 86.667 |
JavaAppBuilder | 12.195 | 52.304 | 35.501 |
Metis Dictionary | 95.804 | 0 | 4.196 |
mvn-gui | 17.105 | 3.947 | 78.947 |
PocketMine-GUI | 40.602 | 20.301 | 39.098 |
SaveMyPass | 33.333 | 0 | 66.667 |
SoccerQuizApp | 45 | 30 | 25 |
Swing Chat | 54.054 | 21.622 | 24.324 |
Mean | 38.812 | 19.864 | 41.324 |
SD | 24.755 | 24.899 | 28.117 |
Median | 41.549 | 12.847 | 35.501 |
4.4 RQ4. Do Developers Revive Dead Methods in Open-source Java Desktop Applications?
4.5 RQ5. In Open-source Java Desktop Applications, Were Dead Methods Mostly Born Dead or Do They Mostly Become Dead Later?
Application | %DeadBornMethods | %DeadBecameMethods | p-value |
---|---|---|---|
4HWC Autonomous Car | 92.593 | 7.407 | 0 |
8_TheWeather | 100 | 0 | − |
BankApplication | 69.259 | 30.741 | 0 |
bitbox | 98.095 | 1.905 | 0 |
Density Converter | 95.139 | 4.861 | 0 |
Deobfuscator-GUI | 98.718 | 1.282 | 0 |
graphics-tablet | 88.698 | 11.302 | 0 |
JavaANPR | 99.578 | 0.422 | 0 |
javaman | 84.507 | 15.493 | 0 |
JDM | 100 | 0 | − |
JPass | 76.623 | 23.377 | 0 |
MBot | 100 | 0 | − |
SMV APP | 77.049 | 22.951 | 0 |
Calculator | 100 | 0 | − |
Desktop Weather Widget | 96.512 | 3.488 | 0 |
IOU | 66.667 | 33.333 | 0.1 |
JavaAppBuilder | 72.087 | 27.913 | 0 |
Metis Dictionary | 100 | 0 | − |
mvn-gui | 69.737 | 30.263 | 0.001 |
PocketMine-GUI | 97.744 | 2.256 | 0 |
SaveMyPass | 100 | 0 | − |
SoccerQuizApp | 80 | 20 | 0 |
Swing Chat | 96.296 | 3.704 | 0 |
Mean | 89.535 | 10.465 | |
SD | 12.038 | 12.038 | |
Median | 96.296 | 3.704 |