The Circumstances in Which Modular Programming Becomes the Favor Choice by Novice Programmers
Total Page:16
File Type:pdf, Size:1020Kb
I.J. Modern Education and Computer Science, 2018, 7, 1-12 Published Online July 2018 in MECS (http://www.mecs-press.org/) DOI: 10.5815/ijmecs.2018.07.01 The Circumstances in which Modular Programming becomes the Favor Choice by Novice Programmers Ilana Lavy Department of Information Systems, Yezreel Valley College, Israel Email: [email protected] Rashkovits Rami Department of Information Systems, Yezreel Valley College, Israel Email: [email protected] Received: 16 May 2018; Accepted: 04 June 2018; Published: 08 July 2018 Abstract—One of the key indicators for testing code quality is the level of modularity. Nevertheless, novice I. INTRODUCTION programmers do not always stick to writing modular code. In this study, we aim to examine the circumstances in The principle of modular design is defined [1] as which novice programmers decide to do so. To address splitting up large computation into a collection of small, this aim, two student groups, twenty each, were given a nearly independent, specialized sub-processes. In other programming assignment, each in a different set-up. The words, modular programming is a design principle that first group was given the assignment in several stages, divides the functionality of a program into modules each each add complexity to the previous one, while the responsible to one aspect of the desired functionality. The second group was given the entire assignment at once. modules are independent and can be easily replaced or The students' solutions were analyzed using the dual- extended with minimal changes in other modules [2]. process theory, cognitive dissonance theory and content Modularity hence supports gradual development, easy analysis methods to examine the extent of modularity. maintenance and reusability. To be able to create a The analysis revealed the following findings: (1) In the modular solution, one needs to possess abstract thinking first group, a minor increase in the number of modular abilities to deconstruct the solution into logical parts, and solutions was found while they progressed along the then integrate them to create the complete solution. stages; (2) The number of modular solutions of the Among the difficulties novice programmers encounter second group was higher than of the first group. Analysis while coping with programming assignments, is the of students' justifications for lack of modularity in the application of the modularity principle in their solutions first group revealed the following. The first stages of the [3]. problem were perceived as rather simple hence many The issue of modularity is part of the curriculum of students did not find any reason to invest in designing a introductory programming course [4]. During this course, modular solution. When the assignment got complex in students are engaged in problem solving in an increasing the following stages, the students realized that a modular level of difficulty. At the beginning of the course, the solution would fit better, hence a cognitive dissonance students learn the basic structures of the programming was raised. Nevertheless, many of them preferred to language, such as variables, conditions, loops etc. decrease the dissonance by continuing their course of Functions and classes are usually taught afterwards. In non-modular solution instead of re-designing a modular order to introduce the basic program structures, educators new one. Students of both groups also attributed their usually use non-modular examples, and give homework non-modular code to lack of explicit criteria for the assignments in which all aspects of the program are evaluation of the code quality that lead them to focus on applied in one module. As a result, students acquire "bad functionality alone. habits" of programming when it comes to modular code writing. These habits are sometimes difficult to change Index Terms—Novice Programmer, Code Modularity, even though students learn to program using functions, Program Design, Cognitive Dissonance Theory, Dual- which enables modular programming. Modular Process Theory. programming necessitates investing considerable mental Copyright © 2018 MECS I.J. Modern Education and Computer Science, 2018, 7, 1-12 2 The Circumstances in which Modular Programming becomes the Favor Choice by Novice Programmers efforts in pre designing the program, hence the "bad stages where each successive stage adds requirements to habits" are difficult to cutoff. However, real-world the previous one. The second group (hereinafter Group-2) software systems are far more complex than homework had to address the same assignment provided at once. assignments, and necessitate modularity for proper In what follows, we present related works and functionality and easy maintenance. Nevertheless, people theoretical background, the study, results and discussion prefer to invest minimal mental efforts in tasks involving and concluding remarks. problem solving, even if it comes at the expense of the solution's quality [5]. The issue of modularity is part of the curriculum of II. RELATED WORKS AND THEORETICAL BACKGROUND introductory programming course [4]. During this course, students are engaged in problem solving in an increasing In what follows, we present a brief theoretical level of difficulty. At the beginning of the course, the background on modularity in programming; dual-process students learn the basic structures of the programming theory; and cognitive dissonance theory. language, such as variables, conditions, loops etc. A. Modularity in programming Functions and classes are usually taught afterwards. In order to introduce the basic program structures, educators Modularity in programming refers to a technique usually use non-modular examples, and give homework design that separates the functionality of a code into assignments in which all aspects of the program are independent, extendible, reusable, maintainable and applied in one module. As a result, students acquire "bad interchangeable modules, each responsible for one aspect habits" of programming when it comes to modular code of the desired behavior of the program [2] Modular code writing. These habits are sometimes difficult to change is obtained by decomposing a problem into sub-problems, even though students learn to program using functions, and designing a solution for each of them as an which enables modular programming. Modular independent unit, accompanied by an interface definition programming necessitates investing considerable mental for their execution (i.e., parameters, return value, etc.). efforts in pre designing the program, hence the "bad Afterwards, these units are integrated to achieve the habits" are difficult to cutoff. However, real-world complete solution to the given problem. The above software systems are far more complex than homework process is recursive in nature because the sub-problems assignments, and necessitate modularity for proper created in the initial decomposition can be broken down functionality and easy maintenance. Nevertheless, people again. During the decomposition, software components prefer to invest minimal mental efforts in tasks involving (e.g., classes, functions) are defined, each with an problem solving, even if it comes at the expense of the appropriate interface. Recursive process can be stopped at solution's quality [5]. different stages of dismantling the problem and the Proper design requires the recursive dismantling of the deeper the level of decomposition, the more time and solution into modules until it is simple units each efforts required to define the components and their responsible to one and only aspect. This recursive process interfaces. In addition, on the "way back", to construct requires abstract thinking and the ability to identify units the complete solution, one should invest time and efforts that can be used to implement multiple functionalities. in assembling the components into an integrated whole For this purpose, the unit design should include its [9]. structure (e.g., variables, algorithm), its inputs (e.g., The concept of modularity in software systems was parameters), and its output (e.g., return value, exception). widely discussed in the research literature and lack of Many programmers in general and novice ones in modularity was found as a source of errors, and costly particular, do not invest sufficient efforts in the solution's maintenance [9, 10, 11, 12]. In addition, it was found that design, due to lack of experience and skills. As a result, modular programming affects the quality of the product many software systems suffers from lack of modularity at in a way that it improves the software's readability and some level [6, 7]. Software that is characterized by poor understanding, facilitates maintenance and increases the modularity cause high error rates and costly maintenance reuse of the software components [11, 12]. [8]. In this study, we examine the level of modularity of In this paper, we examine the level of code modularity code written by novice programmers as a function of the of novice programmers under various conditions. complexity of the problem under examination. Specifically, we set two goals: (1) Examine the B. Dual-process theorey programming style of novice programmers with special focus on modularity depending in the task's level of Dual-process theory deals with the distinction between complexity and in the absence of explicit instructions intuitive and analytical modes of thinking. This theory regarding quality. (2) Examine whether there is a suggests that