Abstract
Some solutions to a programming problem are more elegant or more simple than others and thus more understandable for students. We review desirable properties of example programs from a cognitive and a measurement point of view. Certain cognitive aspects of example programs are captured by common software measures, but they are not sufficient to capture a key aspect of understandability: readability. We propose and discuss a simple readability measure for software, SRES, and apply it to object-oriented textbook examples. Our results show that readability measures correlate well with human perceptions of quality. Compared with other readability measures, SRES is less sensitive to commenting and whitespace. These results also have implications for software maintainability measures.
Similar content being viewed by others
Notes
According to Fowler (1999), a code smell is an indication on the code’s surface level of a potential problem at a deeper level. It is subtle and easy to spot, but not necessarily an actual problem or defect.
DuBay (2004) defines readability as “what makes some texts easier to read than others. It is often confused with legibility, which concerns typeface and layout.”
Pogje as well (Abbas 2010) can be downloaded from http://www.bth.se/com/jub.nsf.
Available from http://www.arrestedcomputing.com/readability/.
Available from https://github.com/darylposnett/readability.
A list of references to the source code of E1..E26 can be downloaded from http://www.bth.se/com/jub.nsf.
References
Abbas, N. (2010). Properties of “good” java examples. Master thesis, Umeå University, Umeå, Sweden.
Armstrong, D. J. (2006). The quarks of object-oriented development. Communications of the ACM, 49(2), 123–128.
Arnaoudova, V., Eshkevari, L., Oliveto, R., Gueheneuc, Y. G., & Antoniol, G. (2010). Physical and conceptual identifier dispersion: Measures and relation to fault proneness. In Proceedings of the 26th IEEE international conference on software maintenance.
Ben-Ari, M. (2010). Objects never?: Well, hardly ever!. Communications of the ACM, 53(9), 32–35.
Benjamin, R. G. (2012). Reconstructing readability: Recent developments and recommendations in the analysis of text difficulty. Educational Psychology Review, 24(1), 63–88.
Börstler, J., Caspersen, M. E., & Nordström, M. (2007). Beauty and the beast—toward a measurement framework for example program quality. Tech. Rep. UMINF-07.23, Dept. of Computing Science, Umeå University, Umeå, Sweden.
Börstler, J., Hall, M. S., Nordström, M., Paterson, J. H., Sanders, K., Schulte, C., et al. (2009). An evaluation of object oriented example programs in introductory programming textbooks. Inroads, 41, 126–143.
Börstler, J., Nordström, M., & Paterson, J. H. (2011). On the quality of examples in introductory java textbooks. ACM Transactions on Computing Education, 11, 3:1–3:21.
Burkhardt, J., Détienne, F., & Wiedenbeck, S. (2002). Object-oriented program comprehension: Effect of expertise, task and phase. Empirical Software Engineering, 7(2), 115–156.
Buse, R., & Weimer, W. (2010). Learning a metric for code readability. IEEE Transactions on Software Engineering, 36(4), 546–558.
Butler, S., Wermelinger, M., Yu, Y., & Sharp, H. (2010). Exploring the influence of identifier names on code quality: An empirical study. In 14th European conference on software maintenance and reengineering, pp 156–165.
CACM. (2002). Hello, world gets mixed greetings. Communications of the ACM, 45(2), 11–15.
Cadwell, P. (2008). Readability and controlled language. Master’s thesis, Dublin City University.
Cant, S., Jeffery, D. R., & Henderson-Sellers, B. (1995). A conceptual model of cognitive complexity of elements of the programming process. Information and Software Technology, 37(7), 351–362.
Clancy, M. (2004). Misconceptions and attitudes that infere with learning to program. In S. Fincher & M. Petre (Eds.), Computer Science Education Research (pp. 85–100). Lisse: Taylor & Francis.
Clark, R., Nguyen, F., & Sweller, J. (2006). Efficiency in learning: Evidence-based guidelines to manage cognitive load. Pfeiffer: Wiley.
Curtis, B., Sheppard, S. B., Milliman, P., Borst, M., & Love, T. (1979). Measuring the psychological complexity of software maintenance tasks with the halstead and mccabe metrics. IEEE Transactions on Software Engineering, 2, 96–104.
De Lucia, A., Di Penta, M., & Oliveto, R. (2011). Improving source code lexicon via traceability and information retrieval. IEEE Transactions on Software Engineering, 37(2), 205–227.
Deimel, L., & Naveda, J. (1990). Reading computer programs: Instructor’s guide and exercises. Tech. Rep. CMU/SEI-90-EM-3, Pittsburgh, PA, USA: Software Engineering Institute.
Deißenböck, F., & Pizka, M. (2006). Concise and consistent naming. Software Quality Journal, 14(3), 261–282.
Dodani, M. H. (2003). Hello world! goodbye skills!. Journal of Object Technology, 2(1), 23–28.
DuBay, W. H. (2004). The principles of readability. Costa Mesa, CA: Impact Information.
Fitzsimmons, A., & Love, T. (1978). A review and evaluation of software science. ACM Computing Surveys (CSUR), 10(1), 3–18.
Flesch, R. (1948). A new readability yardstick. Journal of applied psychology, 32(3), 221.
Foster, J. R. (1993). Cost factors in software maintenance. PhD thesis, School of Engineering and Computer Science, University of Durham, UK.
Flower, M. (1999). Refactoring: Improving the design of existing code. Reading, MA : Addison-Wesley.
Gellenbeck, E., & Cook, C. (1991). An investigation of procedure and variable names as beacons during program comprehension. In Empirical studies of programmers: Fourth workshop, pp 65–81.
Glass, R. (2003). Facts and fallacies of software engineering. Reading, MA : Addison-Wesley.
Gobet, F., Lane, P., Croker, S., Cheng, P., Jones, G., Oliver, I., et al. (2001). Chunking mechanisms in human learning. Trends in Cognitive Sciences, 5(6), 236–243.
Haiduc, S., & Marcus, A. (2008). On the use of domain terms in source code. In Proceedings of the 16th IEEE international conference on program comprehension, pp 113–122.
Halstead, M. (1975). Toward a theoretical basis for estimating programming effort. In Proceedings of the annual ACM/CSC-ER conference, pp 222–224.
Hargis, G. (2000). Readability and computer documentation. Journal of Computer Documentation, 24(3), 122–131.
Høst, E. W., & Østvold, B. M. (2009). Debugging method names. In Proceedings of the 23rd European conference object-oriented programming, pp 294–317.
Jabangwe, R., Börstler, J., Šmite, D., & Wohlin, C. (2014). Empirical evidence on the link between object-oriented measures and external quality attributes: A systematic literature review. Empirical Software Engineering. doi:10.1007/s10664-013-9291-7.
Kramer, J. (2007). Is abstraction the key to computing? Communications of the ACM, 50(4), 36–42.
Lanza, M., Marinescu, R., & Ducasse, S. (2005). Object-Oriented Metrics in Practice. Berlin: Springer.
LaToza, T. D., Venolia, G., & DeLine, R. (2006). Maintaining mental models: A study of developer work habits. In Proceedings of the 28th international conference on software engineering, pp 492–501.
Lawrie, D., Morrell, C., Feild, H., & Binkley, D. (2006). What’s in a name? A study of identifiers. In Proceedings of the 14th IEEE international conference on program comprehension, pp 3–12.
Liblit, B., Begel, A., & Sweetser, E. (2006). Cognitive perspectives on the role of naming in computer programs. In Proceedings of the 18th annual psychology of programming workshop, pp 53–67.
Liz, B., Dreyfus, T., Mason, J., Tsamir, P., Watson, A., & Zaslavsky, O. (2006). Exemplification in mathematics education. In Proceedings of the 30th conference of the international group for the psychology of mathematics education, Vol. 1, pp 126–154.
Marcus, A., Poshyvanyk, D., & Ferenc, R. (2008). Using the conceptual cohesion of classes for fault prediction in object-oriented systems. IEEE Transactions on Software Engineering, 34(2), 287–300.
Martin, J. (1993). Principles of object-oriented analysis and design. Englewood Cliffs NJ : Prentice-Hall.
Mason, J., & Pimm, D. (1984). Generic examples: Seeing the general in the particular. Educational Studies in Mathematics, 15(3), 277–289.
Mayer, R. E. (2004). Should there be a three-strikes rule against pure discovery learning? American Psychologist, 59(1), 14.
McCabe, T. (1976). A complexity measure. IEEE Transactions on Software Engineering, 2(4), 308–320. doi:10.1109/TSE.1976.233837.
Miller, G. (1956). The magical number seven, plus or minus two: Some limits on our capacity for processing information. Psychological review, 63(2), 81.
Nguyen, V. (2010). Improved size and effort estimation models for software maintenance. In Proceedings of the 26th international conference on software maintenance, pp 1–2.
Paas, F., Renkl, A., & Sweller, J. (2003). Cognitive load theory and instructional design: Recent developments. Educational Psychologist, 38(1), 1–4.
Posnett, D., Hindle, A., & Devanbu, P. (2011). A simpler model of software readability. In Proceedings of the 8th working conference on mining software repositories, pp 73–82.
Ragonis, N., & Ben-Ari, M. (2005). A long-term investigation of the comprehension of OOP concepts by novices. Computer Science Education, 15(3), 203–221.
Reimann, P., & Schult, T. J. (1996). Turning examples into cases: Acquiring knowledge structures for analogical problem solving. Educational Psychologist, 31(2), 123–132.
Relf, P. A. (2005). Tool assisted identifier naming for improved software readability: An empirical study. In Proceedings of the 4th international symposium on empirical software engineering (ISESE), pp 53–62.
Riel, A. J. (1996). Object-Oriented design heuristics. Reading, MA : Addison-Wesley.
Salviulo, F., & Scanniello, G. (2014). Dealing with identifiers and comments in source code comprehension and maintenance: Results from an ethnographically informed study with students and professionals. In Proceedings of the 18th international conference on evaluation and assessment in software engineering, pp 48:1–48:10.
Shaft, T. M., & Vessey, I. (2006). The role of cognitive fit in the relationship between software comprehension and modification. MIS Quarterly, 30(1), 29–55.
Sweller, J., & Cooper, G. (1985). The use of worked examples as a substitute for problem solving in learning algebra. Cognition and Instruction, 2, 59–89.
Tennyson, R. D., & Cocchiarella, M. J. (1986). An empirically based instructional design theory for teaching concepts. Review of Educational Research, 56(1), 40–71.
Trafton, J. G., & Reiser, B. J. (1993). Studying examples and solving problems: Contributions to skill acquisition. Tech. rep., Washington, DC, USA: Naval HCI Research Lab.
Tryggeseth, E. (1997). Support for understanding in software maintenance. PhD thesis, Norwegian University of Science and Technology, Trondheim, Norway.
VanLehn, K. (1996). Cognitive skill acquisition. Annual Review of Psychology, 47, 513–539.
Watson, A., & Mason, J. (2002). Extending example spaces as a learning/teaching strategy in mathematics. In Proceedings 26th Conference of the international group for the psychology of mathematics education, Vol. 4, pp 377–384.
Welker, K. (2001). The software maintainability index revisited. CrossTalk, 14, 18–21.
Welker, K. D., Oman, P. W., & Atkinson, G. G. (1997). Development and application of an automated source code maintainability index. Journal of Software Maintenance: Research and Practice, 9(3), 127–159.
Westfall, R. (2001). ‘Hello, world’ considered harmful. Communications of the ACM, 44(10), 129–130.
Woodfield, S. N., Dunsmore, H. E., & Shen, V. Y. (1981). The effect of modularization and comments on program comprehension. In Proceedings of the 5th international conference on software engineering, pp 215–223.
Yip, S. W., & Lam, T. (1994). A software maintenance survey. In Proceedings of the 1st Asia-Pacific software engineering conference, pp 70–79.
Author information
Authors and Affiliations
Corresponding author
Appendix: Measurement results
Appendix: Measurement results
Rights and permissions
About this article
Cite this article
Börstler, J., Caspersen, M.E. & Nordström, M. Beauty and the Beast: on the readability of object-oriented example programs. Software Qual J 24, 231–246 (2016). https://doi.org/10.1007/s11219-015-9267-5
Published:
Issue Date:
DOI: https://doi.org/10.1007/s11219-015-9267-5