Abstract-One of the key indicators for testing code quality is the level of modularity. Nevertheless, novice programmers do not always stick to writing modular code. In this study, we aim to examine the circumstances in which novice programmers decide to do so. To address this aim, two student groups, twenty each, were given a programming assignment, each in a different set-up. The first group was given the assignment in several stages, each add complexity to the previous one, while the second group was given the entire assignment at once. The students' solutions were analyzed using the dualprocess theory, cognitive dissonance theory and content analysis methods to examine the extent of modularity. The analysis revealed the following findings: (1) In the first group, a minor increase in the number of modular solutions was found while they progressed along the stages; (2) The number of modular solutions of the second group was higher than of the first group. Analysis of students' justifications for lack of modularity in the first group revealed the following. The first stages of the problem were perceived as rather simple hence many students did not find any reason to invest in designing a modular solution. When the assignment got complex in the following stages, the students realized that a modular solution would fit better, hence a cognitive dissonance was raised. Nevertheless, many of them preferred to decrease the dissonance by continuing their course of non-modular solution instead of re-designing a modular new one. Students of both groups also attributed their non-modular code to lack of explicit criteria for the evaluation of the code quality that lead them to focus on functionality alone.