Delft University of Technology
The Delta Maintainability Model: Measuring Maintainability of Fine-Grained Code
Changes
di Biase, Marco; Rastogi, Ayushi; Bruntink, Magiel; van Deursen, Arie DOI 10.5281/zenodo.2606632 10.1109/TechDebt.2019.00030 Publication date 2019 Document Version Other version Published in
Proceedings - 2019 IEEE/ACM International Conference on Technical Debt, TechDebt 2019
Citation (APA)
di Biase, M., Rastogi, A., Bruntink, M., & van Deursen, A. (2019). The Delta Maintainability Model:
Measuring Maintainability of Fine-Grained Code Changes. In Proceedings - 2019 IEEE/ACM International Conference on Technical Debt, TechDebt 2019 (pp. 113-122). [8785997] (Proceedings - 2019 IEEE/ACM International Conference on Technical Debt, TechDebt 2019). IEEE .
https://doi.org/10.5281/zenodo.2606632, https://doi.org/10.1109/TechDebt.2019.00030 Important note
To cite this publication, please use the final published version (if applicable). Please check the document version above.
Copyright
Other than for strictly personal use, it is not permitted to download, forward or distribute the text or part of it, without the consent of the author(s) and/or copyright holder(s), unless the work is under an open content license such as Creative Commons. Takedown policy
Please contact us and provide details if you believe this document breaches copyrights. We will remove access to the work immediately and investigate your claim.
This work is downloaded from Delft University of Technology.
The Delta Maintainability Model: Measuring
Maintainability of Fine-Grained Code Changes
Technical Report
Marco di Biase
∗†, Ayushi Rastogi
†, Magiel Bruntink
∗, Arie van Deursen
†∗Software Improvement Group - Amsterdam, The Netherlands †Delft University of Technology - Delft, The Netherlands
Email:∗[m.dibiase, m.bruntink]@sig.eu, †[a.rastogi, Arie.vanDeursen]@tudelft.nl I. INTRODUCTION
This technical report contains definitions for the paper ’The Delta Maintainability Model: Measuring Maintainability of Fine-Grained Code Changes’ submitted to the 2nd International Conference on Technical Debt (TechDebt 2019) -Montr´eal, Canada - May 26–27, 2019.
II. DEFINTIONS
Figure 1 provides an overview of the model and its under-lying calculations.
The calculation of the DMM consists of two levels. The first level (Figure 1a) defines how a code change is mapped into several Risk Profile Deltas, which are an extension of the Risk Profile concept used in the SIG-MM. Then, the second level (Figure 1b) defines how the individual Risk Profile Deltas are combined to create a Delta Score at the commit level.
The input to DMM is a delta, or code change, consisting of the source code files that were involved in the change. More formally, we define a delta D as a set of n tuples hf0, f i, with f0 and f the versions of a file prior to and after the change: Definition 1 — Delta.
D = {hfi0, fii|i ∈ {1..n}}.
Risk profile deltas are defined with respect to the set CP of relevant code properties, of which we have five, and a set of four Risk Categories:
Definition 2 — Code Properties, Risk Categories. CP= hUnit Size, Unit Complexity, Unit Interfacing,
Duplication, Module Couplingi RC= hlow, med, high, very-highi
Next, we build up our definition of risk increases and decreases. We define a Risk Profile Delta between files f0 and f , relative to a Code Property cp and Risk Category r: Definition 3 — Risk Profile Delta (RPD).
RPD(f0, f, cp, r) = LOC(f, cp, r) − LOC(f0, cp, r) In definition 3, LOC maps its arguments to the number of Lines Of Code in the Risk Category r of the code property cp for a specific file f . All Code Properties are mapped to Lines
Of Code as specified by the SIG-MM [1] and all measurements are computed at file level.
Risk Profile Deltas are separated into increases and de-creases:
Definition 4 — Risk Profile Delta Increase (RPDI) and Decrease (RPDD).
RPDI(f0, f, cp, r) = max(0, RPD(f0, f, cp, r)) RPDD(f0, f, cp, r) = | min(0, RPD(f0, f, cp, r)) | With this, we have the increases and decreases for each property at each Risk Category and for each file, as shown at the bottom of Figure 1a in step 4. We next aggregate these to the commit level, following Figure 1b.
Definition 5 — Commit Risk Profile Delta Increase (CRPDI) and Decrease (CRPDD). CRPDI(cp, r) = X hf0,f i∈D RPDI(f0, f, cp, r) CRPDD(cp, r) = X hf0,f i∈D RPDD(f0, f, cp, r)
To detect which components of the definition 5 have high maintainability, we define Low Risk Profile Delta as the increase in low risk code summed to a decrease in medium/high/very-high risk code (both of which are good). Definition 6 — Low Risk Profile Delta (LRPD).
LRPD(cp) = CRPDI(cp, low)+ X
h∈{medium, high, very-high}
CRPDD(cp, h) The goal of definition 6 is to sum Commit Risk Profile Deltas that are highly maintainable. In fact: 1) CRP DI(cp, low) adds code in the low risk category; there-fore, it is highly maintainable; 2) CRP DD(cp, medium) + CRP DD(cp, high) + CRP DD(cp, very-high) removes code from the higher risk categories; therefore, it is highly main-tainable.
Similarly, we have to define components of the definition 5 that have low maintainability. Therefore, we define High Risk Deltas as a decrease in low risk code, or an increase in code that is not low risk:
Risk Profile Deltas per Risk Profile per Code Property
per File
- ≥0
-Risk Profile Delta Increase (RPDI) Risk Profile Delta Decrease
(RPDD)
<0
4
# LOC # LOC’ ∆ LOC
LOC ∆ # LOC’
# LOC # LOC per Risk Profile
per Code Property per File
# LOC’ # LOC’ # LOC’ # LOC’ # LOC # LOC # LOC # LOC 3
Categorize System Properties using
Benchmarked Risk Thresholds Extract Source Code Measurements per each File
(Unit Size, Duplication, …)
Low Medium High Very-high Low Medium High Very-high
2
Commit CommentsCommentCommentsReview Commit Commit C
Files modified from commit C extracted from commit C’ (parent)
File F1’ File F2’ File Fn’
Files modified from commit C
File F1 File F2 File Fn 1
(A) LEVEL1:RISK PROFILE DELTAS.
Delta Maintainability Score (DMM Score) =
DS Unit Size + DS Duplication + … 5
defined per each System Property Delta Score (DS) = LPRD LPRD + HRPD 7 8
Low Risk Profile Delta (LRPD) High Risk Profile Delta
(HRPD) + + + + + + = = CRPDD Medium CRPDI Medium CRPDD High CRPDI High CRPDI Low CRPDD Low CRPDD Very-hi CRPDI Very-hi
Aggregate Commit Risk Profile Deltas 6 + + + + Low Medium High Very-high Calculate Commit Risk Profile Delta
per each Risk Profile
Commit Risk Profile Delta Decreases (CRPDD)
= = Commit Risk Profile Delta Increases (CRPDI)
5
LOC
∆ ∆ LOC ∆ LOC
LOC
∆ ∆ LOC ∆ LOC Files modified from commit C
Risk Profiles Delta Increases/Decreases per each System Property (Unit Size, Duplication, …)
4 File F1 LOC ∆ LOC ∆ File F2 LOC ∆ LOC ∆ File Fn LOC ∆ LOC ∆
(B) LEVEL2:DELTA SCORES. FIGURE1. OVERVIEW OF THEDMM.
Definition 7 — High Risk Profile Delta (HRPD). HRPD(cp) = CRPDD(cp, low)+
X
h∈{medium, high, very-high}
CRPDI(cp, h) The goal of definition 7 is dual to that of defini-tion 6, i.e., to sum Commit Risk Profile Deltas that are less maintainable. In fact: 1) CRP DD(cp, low) removes code in the low risk category; therefore, its maintainabil-ity is low; 2) CRP DI(cp, medium) + CRP DI(cp, high) + CRP DI(cp, very-high) adds code from the higher risk cate-gories; therefore, they are less maintainable.
The Delta Score for a Code Property cp then is the propor-tion of low risk delta:
Definition 8 — Delta Score (DS). DS(cp) = LRPD(cp)
LRPD(cp) + HRPD(cp)
The rationale behind definition 8 is that we compute the amount of Low Risk Profile Delta over the total amount of Risk Profile Delta measured. Given a Code Property, the resulting value represents the percentage of highly main-tainable Delta Risk Profile over its total. Finally, the Delta Maintainability Model Score is the mean of all the single Code Properties in one value:
Definition 9 — Delta Maintainability Model (DMM) Score.
DMM Score= X cp∈CP DS(cp) |CP | REFERENCES
[1] T. L. Alves, J. P. Correia, and J. Visser. Benchmark-Based Aggregation of Metrics to Ratings. In 2011 Joint Conference of the 21st International Workshop on Software Measurement and the 6th International Conference on Software Process and Product Measurement, pages 20–29, 2011.