What makes a readable code? A causal analysis method

被引:2
|
作者
Mi, Qing [1 ]
Chen, Mingjie [2 ]
Cai, Zhi [1 ,3 ]
Jia, Xibin [1 ]
机构
[1] Beijing Univ Technol, Fac Informat Technol, Beijing, Peoples R China
[2] South China Univ Technol, Sch Software Engn, Guangzhou, Peoples R China
[3] Beijing Univ Technol, Fac Informat Technol, 100 Pingleyuan,Chaoyang Dist, Beijing, Peoples R China
来源
SOFTWARE-PRACTICE & EXPERIENCE | 2023年 / 53卷 / 06期
基金
北京市自然科学基金; 新加坡国家研究基金会;
关键词
causal analysis; code readability; PC algorithm; program comprehension;
D O I
10.1002/spe.3192
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
Context:Code readability is one of the most important quality attributes for software source code. To investigate which features affect code readability, most existing studies rely on correlation-based methods. However, spurious correlations (a mathematical relationship wherein two variables appear to be causal but are not) involved in correlation-based methods may affect research conclusions. Objective:In order to remove spurious correlations and obtain conclusions from the perspective of causation as to what makes a readable code, we propose a causal theory-based approach to analyze the relationship between code features and code readability scores. Method:First, we adopt the PC algorithm and additive noise models to construct the causal graph on the basis of the selected code features. Then, we use the linear regression algorithm based on the back-door criterion to obtain the causal effect of different features on code readability. Result:We conduct a set of experiments on readability data labeled by human annotators. The experimental results show that the average number of comments positively impacts code readability, with each additional unit increasing the code readability score by 0.799 points. Whereas the average number of assignments, identifiers, and periods have a negative impact, with each additional unit decreasing the code readability score by 0.528, 0.281, and 0.170 points respectively. Conclusion:We believe that our findings will provide developers with a better understanding of the patterns behind code readability, and guide developers to optimize their code as the ultimate goal.
引用
收藏
页码:1391 / 1409
页数:19
相关论文
共 50 条
  • [1] Identifying causal mechanisms in psychotherapy: What can we learn from causal mediation analysis?
    Hesser, Hugo
    CLINICAL PSYCHOLOGY & PSYCHOTHERAPY, 2022, 29 (03) : 1050 - 1058
  • [2] What does this Python']Python code do? An exploratory analysis of novice students' code explanations
    van der Werf, Vivian
    Aivaloglou, Efthimia
    Hermans, Felienne
    Specht, Marcus
    CSERC'21: THE 10TH COMPUTER SCIENCE EDUCATION RESEARCH CONFERENCE, 2021, : 94 - 107
  • [3] What determines health: a causal analysis using county level data
    Andrew J. Rettenmaier
    Zijun Wang
    The European Journal of Health Economics, 2013, 14 : 821 - 834
  • [4] What determines health: a causal analysis using county level data
    Rettenmaier, Andrew J.
    Wang, Zijun
    EUROPEAN JOURNAL OF HEALTH ECONOMICS, 2013, 14 (05): : 821 - 834
  • [5] Visceral fat estimation method by bioelectrical impedance analysis and causal analysis
    Nakajima, Hiroshi
    Tasaki, Hiroshi
    Tsuchiya, Naoki
    Hamaguchi, Takehiro
    Shiga, Toshikazu
    INDEPENDENT COMPONENT ANALYSES, WAVELETS, NEURAL NETWORKS, BIOSYSTEMS, AND NANOENGINEERING IX, 2011, 8058
  • [6] Lost Causal: Debunking Myths About Causal Analysis in Philanthropy
    Lynn, Jewlya
    Stachowiak, Sarah
    Coffman, Julia
    FOUNDATION REVIEW, 2021, 13 (03): : 17 - 29
  • [7] Causal inference in educational research: Causal analysis in crosssectional observational studies
    Martinez-Abad, Fernando
    Leon, Jaime
    RELIEVE-REVISTA ELECTRONICA DE INVESTIGACION Y EVALUACION EDUCATIVA, 2023, 29 (02):
  • [8] A graph-based code representation method to improve code readability classification
    Qing Mi
    Yi Zhan
    Han Weng
    Qinghang Bao
    Longjie Cui
    Wei Ma
    Empirical Software Engineering, 2023, 28
  • [9] Lost Causal: Debunking Myths About Causal Analysis in Philanthropy - With 2024 Prologue
    Lynn, Jewlya
    Stachowiak, Sarah
    Coffman, Julia
    FOUNDATION REVIEW, 2024, 16 (01): : 41 - 54
  • [10] A causal analysis of time-varying speed camera safety effects based on the propensity score method
    Li, Haojie
    Zhang, Yingheng
    Ren, Gang
    JOURNAL OF SAFETY RESEARCH, 2020, 75 : 119 - 127