Influencia del uso de recomendaciones de legibilidad en la facilidad de comprensión de software: Un estudio experimental

Miniatura

Autores

Lubo Argumedo, Sergio Luis

Director

Aponte Melo, Jairo Hernan

Tipo de contenido

Documento de trabajo

Idioma del documento

Español

Fecha de publicación

2019-10-08

Título de la revista

ISSN de la revista

Título del volumen

Documentos PDF

Resumen

Una de las actividades más frecuentes en mantenimiento de software es la lectura y comprensión de código fuente la cual demanda una proporción considerable del tiempo de los desarrolladores de software. Si el código fuente, no está escrito siguiendo buenas prácticas de programación los tiempos de mantenimiento de este pueden incrementarse. Con el propósito de disminuir los tiempos de lectura y comprensión es necesario por tanto considerar qué tan legible es el código fuente. El consenso general es que el código fuente debe escribirse pensando en minimizar el tiempo que tardarán otros desarrolladores en leerlo y comprenderlo. En esta investigación, se realizó un experimento controlado para analizar dos reglas de legibilidad de anidamiento y bucles. Se utilizaron 32 fragmentos (métodos) Java en cuatro categorías: unos que siguen la regla, otros que no siguen la regla y que son lógicamente correctos o incorrectos. El experimento se realizó en línea con 275 participantes. Los resultados indican que minimizar el anidamiento de estructuras de control disminuye el tiempo que los desarrolladores requieren para leer y comprender código fuente, aumenta su nivel de confianza sobre el grado de comprensión del código y también mejora la capacidad para encontrar errores (bugs). Los resultados también muestran que la regla de evitar el uso de bucles do/while no tuvo impacto significativo en ninguno de los aspectos analizados. Por último, al ser un experimento totalmente en inglés, también se encontró que cuanto mayor era el nivel de conocimiento en inglés los resultados asociados a la regla de minimizar el anidamiento fueron mejores. Se analizan las implicaciones de estos hallazgos sobre legibilidad y comprensión de código fuente.
Software developers spend a significant amount of time reading source code. If code is not written with readability in mind, it impacts the time required to maintain it. In order to alleviate the time taken to read and understand code, it is important to consider how readable the code is. The general consensus is that source code should be written to minimize the time it takes for others to read and understand it. In this paper, we conduct a controlled experiment to assess two code readability rules: nesting and looping. We test 32 Java methods in four categories: ones that follow/do not follow the readability rule and that are correct/incorrect. The study was conducted online with 275 participants. The results indicate that minimizing nesting decreases the time a developer spends reading and understanding source code, increases her level of confidence about her own understanding of the code, and also suggests that it improves her ability to find bugs. The results also show that avoiding the do-while statement had no significant impact on level of understanding, time spent reading and understanding, confidence in understanding, or ease of finding bugs. It was also found that the better knowledge of English a participant had, the more their readability and comprehension confidence ratings were affected by the minimize nesting rule. We discuss the implications of these findings for code readability and comprehension.

Abstract

Descripción Física/Lógica/Digital

Palabras clave

Citación

R. Brooks, «Towards a theory of the comprehension of computer programs,» International journal of man-machine studies, vol. 18, pp. 543-554, 1983.
E. Soloway y K. Ehrlich, «Empirical studies of programming knowledge,» IEEE Transactions on software engineering, Vols. %1 de %2SE-10, pp. 595-609, 1984.
M.-A. Storey, «Theories, methods and tools in program comprehension: past, present and future,» de 13th International Workshop on Program Comprehension (IWPC'05), 2005.
[4] A. Mayrhauser y A. M. Vans, «Program understanding behavior during debugging of large scale software,» de Papers presented at the seventh workshop on Empirical studies of programmers, 1997.
[5] R. Flesch, «A new readability yardstick,» Journal of Applied Psychology, vol. 32, pp. 221-233, 1948.
[6] T. Busjahn, R. Bednarik, A. Begel, M. Crosby, J. H. Paterson, C. Schulte, B. Sharif y S. Tamm, «Eye Movements in Code Reading: Relaxing the Linear Order,» de Proceedings of the 2015 IEEE 23rd International Conference on Program Comprehension, Florence, 2015.
[7] S. Scalabrino, G. Bavota, C. Vendome, M. Linares-Vásquez, D. Poshyvanyk y R. Oliveto, «Automatically Assessing Code Understandability: How Far Are We?,» de Proceedings of the 32nd IEEE/ACM International Conference on Automated Software Engineering, Urbana-Champaign, IL, USA, 2017.
[8] S. Scalabrino, M. Linares-Vásquez, D. Poshyvanyk y R. Oliveto, «Improving code readability models with textual features,» de 2016 IEEE 24th International Conference on Program Comprehension (ICPC), 2016.
[9] J. Börstler, M. E. Caspersen y M. Nordström, «Beauty and the Beast: On the Readability of Object-oriented Example Programs,» Software Quality Journal, vol. 24, pp. 231-246, 2016.
[10] A. Trockman, K. Cates, M. Mozina, T. Nguyen, C. Kästner y B. Vasilescu, «"Automatically assessing code understandability" reanalyzed: combined metrics matter,» de Proceedings of the 15th International Conference on Mining Software Repositories, 2018.
[11] K. B. Lakshmanan, S. Jayaprakash y P. K. Sinha, «Properties of Control-Flow Complexity Measures,» IEEE Transactions on Software Engineering, vol. 17, pp. 1289-1295, 1991.
[12] G. K. Gill y C. F. Kemerer, «Cyclomatic complexity density and software maintenance productivity,» IEEE Transactions on Software Engineering, vol. 17, pp. 1284-1288, 1991.
[13] A. Jbara, A. Matan y D. G. Feitelson, «High-MCC functions in the Linux kernel,» de 2012 20th IEEE International Conference on Program Comprehension (ICPC), 2012.
[14] S. Ajami, Y. Woodbridge y D. G. Feitelson, «Syntax, Predicates, Idioms - What Really Affects Code Complexity?,» de 2017 IEEE/ACM 25th International Conference on Program Comprehension (ICPC), 2017.
[15] J. Shao y Y. Wang, «A new measure of software complexity based on cognitive weights,» Canadian Journal of Electrical and Computer Engineering, vol. 28, pp. 69-74, 2003.
[16] Y. Wang, «Cognitive Complexity of Software and its Measurement,» de 2006 5th IEEE International Conference on Cognitive Informatics, 2006.
[17] J. C. Johnson, S. Lubo, N. Yedla, J. Aponte y B. Sharif, «An Empirical Study Assessing Source Code,» de 35th IEEE International Conference on Software Maintenance and Evolution (ICSME), Cleveland, OH USA, 2019.
[18] D. Lawrie, C. Morrell, H. Feild y D. Binkley, «What's in a Name? A Study of Identifiers,» de 14th IEEE International Conference on Program Comprehension (ICPC'06), 2006.
[19] D. Binkley, M. Davis, D. Lawrie, J. I. Maletic, C. Morrell y B. Sharif, «The Impact of Identifier Style on Effort and Comprehension,» Empirical Software Engineering, vol. 18, pp. 219-276, 2013.
[20] A. Schankin, A. Berger, D. V. Holt, J. C. Hofmeister, T. Riedel y M. Beigl, «Descriptive Compound Identifier Names Improve Source Code Comprehension,» de Proceedings of the 26th Conference on Program Comprehension, Gothenburg, 2018.
[21] S. Fakhoury, Y. Ma, V. Arnaoudova y O. Adesope, «The Effect of Poor Source Code Lexicon and Readability on Developers' Cognitive Load,» de Proceedings of the 26th Conference on Program Comprehension, Gothenburg, 2018.
[22] T. R. Beelders y J.-P. L. Plessis, «Syntax highlighting as an influencing factor when reading and comprehending source code,» Journal of Eye Movement Research, vol. 9, 2015.
[23] J. Feigenspan, C. Kästner, S. Apel, J. Liebig, M. Schulze, R. Dachselt, M. Papendieck, T. Leich y G. Saake, «Do Background Colors Improve Program Comprehension in the #Ifdef Hell?,» Empirical Software Engineering, vol. 18, pp. 699-745, 2013.
[24] R. P. L. Buse y W. R. Weimer, «Learning a Metric for Code Readability,» IEEE Transactions on software engineering, vol. 36, pp. 546-558, 2010.
[25] R. M. Santos y M. A. Gerosa, «Impacts of Coding Practices on Readability,» de Proceedings of the 26th Conference on Program Comprehension, Gothenburg, 2018.
[26] M. E. Hansen, R. L. Goldstone y A. Lumsdaine, «What Makes Code Hard to Understand?,» CoRR, vol. abs/1304.5257, 2013.
[27] A. Wulff-Jensen, K. Ruder, E. Triantafyllou y L. E. Bruni, «Gaze Strategies Can Reveal the Impact of Source Code Features on the Cognitive Load of Novice Programmers,» de Advances in Neuroergonomics and Cognitive Engineering, 2019.
[28] E. R. Iselin, «Conditional statements, looping constructs, and program comprehension: an experimental study,» International Journal of Man-Machine Studies, vol. 28, pp. 45-66, 1988.
[29] J. Borstler y B. Paech, «The Role of Method Chains and Comments in Software Readability and Comprehension-An Experiment,» IEEE Transactions on Software Engineering, vol. 42, pp. 886-898, 2016.
[30] T. Sedano, «Code Readability Testing, an Empirical Study,» de 2016 IEEE 29th International Conference on Software Engineering Education and Training (CSEET), 2016.
[31] D. Boswell y T. Foucher, The Art of Readable Code, O'Reilly Media, Inc., 2011.
[32] R. C. Martin, Clean Code: A Handbook of Agile Software Craftsmanship, 1 ed., Upper Saddle River, NJ, USA: Prentice Hall PTR, 2008.