Skip to main content
Computer Applications in Engineering EducationVolume 32, Issue 1, January 2024, Article number e22685

Assessing code readability in Python programming courses using eye-tracking(Article)

  Save all to author list
  • aFaculty of Technical Sciences, University of Novi Sad, Novi Sad, Serbia
  • bSingidunum University, Belgrade, Serbia

Abstract

Code readability models are typically based on the code's structural and textual features, considering code readability as an objective category. However, readability is inherently subjective and dependent on the knowledge and experience of the reader analyzing the code. This paper assesses the readability of Python code statements commonly used in undergraduate programming courses. Our readability model is based on tracking the reader's eye movement during the while-read phase. It uses machine learning (ML) techniques and relies on a novel set of features—observational features—that capture how the readers read the code. We experimented by tracking the eye movement of 90 undergraduate students while assessing the readability of 48 Python code snippets. We trained an ML model that predicts readability based on the collected observational data and the code snippet's structural and textual features. In our experiments, the XGBoost classifier trained using observational features exclusively achieved the best results (0.85 F-measure). Using correlation analysis, we identified Python statements most affecting readability for undergraduate students and proposed implications for teaching Python programming. In line with findings for Java language, we found that constructs related to the code's size and complexity hurt the code's readability. Numerous comments also hindered readability, potentially due to their association with less readable code. Some Python-specific statements (list comprehension, lambda function, and dictionary comprehension) harmed code readability, even though they were part of the curriculum. Tracking students' gaze indicated some additional factors, most notably nonlinearity introduced by if, for, while, try, and function call statements. © 2023 Wiley Periodicals LLC.

Author keywords

code readabilityempirical studyeye trackingmachine learningPython

Indexed keywords

Engineering controlled terms:Codes (symbols)Eye movementsEye trackingHigh level languagesMachine learningStudents
Engineering uncontrolled termsCode readabilityEmpirical studiesEye-trackingMachine-learningProgramming coursePython codePython programmingStructural featureTextual featuresUndergraduate students
Engineering main heading:Python

Funding details

Funding sponsor Funding number Acronym
451‐03‐47/2023‐01/200156
Science Fund of the Republic of Serbia6521051
  • 1

    This research was supported by the Science Fund of the Republic of Serbia, Grant No 6521051, AI‐Clean CaDET and the Ministry of Science, Technological Development and Innovation through project no. 451‐03‐47/2023‐01/200156 “Innovative scientific and artistic research from the FTS (activity) domain.”

  • ISSN: 10613773
  • CODEN: CAPEE
  • Source Type: Journal
  • Original language: English
  • DOI: 10.1002/cae.22685
  • Document Type: Article
  • Publisher: John Wiley and Sons Inc

  Savić, G.; University of Novi Sad, Faculty of Technical Sciences, Trg Dositeja Obradovića 6, Novi Sad, Serbia;
© Copyright 2024 Elsevier B.V., All rights reserved.

Cited by 1 document

Sampaio, I.B. , Sampaio, A.
Replication of a Study about the Impact of Method Chaining and Comments on Readability and Comprehension
(2024) ICCQ 2024 - Proceedings of the 4th International Conference on Code Quality
View details of this citation
{"topic":{"name":"Source Codes; Information Retrieval; Software Engineering","id":19830,"uri":"Topic/19830","prominencePercentile":84.267166,"prominencePercentileString":"84.267","overallScholarlyOutput":0},"dig":"4e50ee7204bf48a2c19630675cc1b16854ce542e3b40326d11446abea130e722"}

SciVal Topic Prominence

Topic:
Prominence percentile: