Gespeichert in:
Bibliographische Detailangaben
Hauptverfasser: Saha, Subarna, Hasan, Alif Al, Shifat, Fariha Tanjim, Imran, Mia Mohammad
Format: Preprint
Veröffentlicht: 2026
Schlagworte:
Online-Zugang:https://arxiv.org/abs/2603.16791
Tags: Tag hinzufügen
Keine Tags, Fügen Sie den ersten Tag hinzu!
_version_ 1866911600166830080
author Saha, Subarna
Hasan, Alif Al
Shifat, Fariha Tanjim
Imran, Mia Mohammad
author_facet Saha, Subarna
Hasan, Alif Al
Shifat, Fariha Tanjim
Imran, Mia Mohammad
contents Novice programmers often struggle to comprehend code due to vague naming, deep nesting, and poor structural organization. While explanations may offer partial support, they typically do not restructure the code itself. We propose code refactoring as cognitive scaffolding, where cognitively guided refactoring automatically restructures code to improve clarity. We operationalize this in CDDRefactorER, an automated approach grounded in Cognitive-Driven Development that constrains transformations to reduce control-flow complexity while preserving behavior and structural similarity. We evaluate CDDRefactorER using two benchmark datasets (MBPP and APPS) against two models (gpt-5-nano and kimi-k2), and a controlled human-subject study with novice programmers. Across datasets and models, CDDRefactorER reduces refactoring failures by 54-71% and substantially lowers the likelihood of increased Cyclomatic and Cognitive complexity during refactoring, compared to unconstrained prompting. Results from the human study show consistent improvements in novice code comprehension, with function identification increasing by 31.3% and structural readability by 22.0%. The findings suggest that cognitively guided refactoring offers a practical and effective mechanism for enhancing novice code comprehension.
format Preprint
id arxiv_https___arxiv_org_abs_2603_16791
institution arXiv
publishDate 2026
record_format arxiv
spellingShingle Improving Code Comprehension through Cognitive-Load Aware Automated Refactoring for Novice Programmers
Saha, Subarna
Hasan, Alif Al
Shifat, Fariha Tanjim
Imran, Mia Mohammad
Software Engineering
Novice programmers often struggle to comprehend code due to vague naming, deep nesting, and poor structural organization. While explanations may offer partial support, they typically do not restructure the code itself. We propose code refactoring as cognitive scaffolding, where cognitively guided refactoring automatically restructures code to improve clarity. We operationalize this in CDDRefactorER, an automated approach grounded in Cognitive-Driven Development that constrains transformations to reduce control-flow complexity while preserving behavior and structural similarity. We evaluate CDDRefactorER using two benchmark datasets (MBPP and APPS) against two models (gpt-5-nano and kimi-k2), and a controlled human-subject study with novice programmers. Across datasets and models, CDDRefactorER reduces refactoring failures by 54-71% and substantially lowers the likelihood of increased Cyclomatic and Cognitive complexity during refactoring, compared to unconstrained prompting. Results from the human study show consistent improvements in novice code comprehension, with function identification increasing by 31.3% and structural readability by 22.0%. The findings suggest that cognitively guided refactoring offers a practical and effective mechanism for enhancing novice code comprehension.
title Improving Code Comprehension through Cognitive-Load Aware Automated Refactoring for Novice Programmers
topic Software Engineering
url https://arxiv.org/abs/2603.16791