Keywords

1 Introduction

Decomposition in programming refers to the process of breaking down a higher-level problem into sub-problems, allowing programmers to focus independently on each sub-problem [22]. Functions, procedures and methods are form of abstractions, serving at the same time as decomposition mechanism. They allow dividing a given problem into several simpler tasks, then combining them together for the full solution [19].

Programmers have been observed to under-use different forms of abstractions, thus not fulfilling their potential benefits [11, 12]. In this research, we approach the population of high-school students in the early phases of learning programming, in order to investigate what it is that leads programmers, from the very start of their familiarity and experience with code development, to under-use functions, one of the most basic forms of abstraction. More specifically, the objective of this ongoing research is to investigate how and when students use functions, as well as the reasons underlying their decisions whether to use them. Preliminary results obtained via a pilot study, demonstrate that students do not use functions unless they are explicitly instructed to do so, despite their evident familiarity with functions and their proper use. In order to investigate the reasons underlying this behavior, we borrowed a theory and related concepts from cognitive psychology research: the dual-process theory, cognitive laziness, the principle of least effort and, and comfort zone. In this paper we demonstrate how they can useful for making sense of the data obtained.

2 Related Work

Not using functions is not a mistake per-se, but can be inefficient in many cases. It is one of the basic mechanisms for code modularization, decomposition and reusability: “Modularization allows one to decompose a system into functional units, to impose hierarchical ordering on functional usage, to implement data abstractions, and to develop independently useful subsystems” [13]. High modularity allows for separation of concerns, namely dealing separately with each module’s details while ignoring other modules’ detail, and later with all features of all modules and the relationships between the modules, in order to combine them into a coherent system.

Code modularity facilitates code reuse, namely the ability to use parts of a computer program written previously, aiming to increase productivity and quality in large-scale software development projects [7].

Code modularity mechanisms, such as functions, are forms of abstraction. Abstraction in computer science(CS) involves throwing away detail while keeping the essential structure, and is a skill that is hard to master [1, 14]. Kramer [18] suggests that it is abstraction that differentiates good from weaker students. Functions, in particular, are widely accepted to be a difficult concept to learn [20].

Previous works studying programming skills of high school students have mainly focused on investigating, exploring and reviewing programming mistakes [5, 23]. For example, Brown [5] lists 18 of the most common student mistakes, which vary from simple mistakes, as in the case of incorrect semicolon at the end of a method header, to more complicated ones, such as not controlling the program flow properly. But programming mistakes are not only done by students; even experienced software developers make mistakes, such as confusing inheritance direction or failing to identify objects or classes [11, 12], demonstrating the resilience or such difficulties.

Other directions of research focused on the processes involved in teaching or in learning to program, and on how to improve these processes for better results. Such proposed improvements include, for example, having teachers present real-life examples [3]; letting the students write pseudo-code solutions in order to focus more on the structure and not be held back by syntax [8]; allocating more time in class for exercises, with the teacher as guider [2]; and, letting students learn from their mistakes [10]. No such improvement technique was examined in the specific context of functions.

3 Theoretical Background

The dual-process theory deals with the question of why people make mistakes that could have been avoided given their own knowledge [16]. The theory suggests that two separate cognitive systems operate in our mind: intuitive and analytical thinking. The first system (S1) deals with immediate, automatic thinking processes, based on heuristics. The second system (S2) is responsible for analytical processing. S1 results in fast and automatic solutions, while S2 in slower, consciously analyzed ones [16].

Cognitive laziness refers to the situation in which people may be content with a “good enough” solution, despite their awareness that a better solution can be achieved if they invest more effort [9]. Although there may be a better solution, people tend to choose the solution that is enough for their immediate goals. Intuitive judgment and common sense are examples of mechanism used due to cognitive laziness [21].

The principle of least effort explains that people (or even animals or smart machines) will naturally choose the path of least effort, with the least resistance, having the desire to reach things quickly and easily [25]. Accordingly, a person facing a certain situation, tends to choose the solution with the least effort from all possible solutions rising in the horizon (as perceived by that specific person) [6].

Comfort zone is a situation in which a person behaves in an anxiety neutral condition, and acts limitedly, in order to sustain a steady, risk-free state of tasks’ performance [24]. The term comfort zone refers to a psychological state in which a person feels comfortable, at ease and in control [24], and suggests that individuals may choose the less stressful and challenging solution, in order to be in the more comfortable and less adventurous state, from their point of view [4].

4 Pilot Study – Method and Settings

The objectives of this research are to empirically explore our initial observation that students do not use functions when they deal with programming tasks, unless they are explicitly asked to do so, and to understand the reasons underlying this behavior.

The population of pilot study included 10 students of the 12th grade, who majored in CS in the school in which the first author teaches. These students had already learned and exercised the use of functions and were trained in programming tasks.

During the study, the students had free access to their books and notebooks. Each student was handed three worksheets which included programming tasks. The worksheets were given one at a time; the next sheet given only after the participants completed the previous one, in order to prevent them from checking questions in the next worksheet thus possibly affecting the way they solve the questions in the current one.

The first worksheet included three tasks, with a shared functionality to all, but with no further information. It instructed to add a number to all items in a given array, with the tasks differing only in the value of the added number. The second worksheet included three tasks of the same level with a shared functionality and an instruction, at the bottom, asking participants to pay attention to what is common in the tasks. The third worksheet also included three tasks of the same level, with an instruction to write a function for the common functionality and to use it to solve the three tasks.

Data collection was based mainly on: (1) Written solutions collected from the participants after each task; and (2) group interviews [17] about their solutions. We used a semi-structured approach with no rigorous set of questions, so to allow diversion [15].

In analyzing the worksheets’ answers, we looked for general solutions, rather than fully correct ones; we did not consider syntax or any other compilation errors but rather considered the intention behind the students’ answers. We classified the answers to those using functions and those that do not. During the data analysis, we looked for explanations for the obtained results. Specifically, in analyzing the qualitative data from the transcribed group interview, we mapped students’ quotes to a corresponding cognitive concept based on an initial set of guidelines we developed:

5 Results

In worksheet1, all students used a for loop, for each task, while changing the value of the added number each time. Not even a single student wrote a function for the common functionality for reusing it in the different tasks. When the students were later whether they had noticed a common functionality between the tasks, one student raised his hand. When asked why he did nothing about it, he answered: “I didn’t know what to do with this common functionality; I just solved the question as required.”

In worksheet2, all students used for loops, the same way as in worksheet1, even though they were asked here to pay attention to what is common between the tasks. When asked about their solutions, all students stated that they had noticed the comment about the commonality. When asked why they did not use a function instead of repeating the same code with a change of value, they gave the following explanations:

  1. 1.

    “I wrote the first thing that crossed my mind.”

  2. 2.

    “I answered without thinking too much; it was almost automatic.”

  3. 3.

    “I answered in the easiest way.”

  4. 4.

    “It is more comfortable for me to solve it this way.”

  5. 5.

    “The number of questions is small, why the effort?”

  6. 6.

    “I answered in the simplest way, straightforward, without complication.”

  7. 7.

    “I answered in the way with the least possibility to make mistakes.”

  8. 8.

    “The tasks did not require us to write a function. Had that been a requirement in the assignment, I would have no problem doing that.”

  9. 9.

    “There were only few questions and the questions themselves were easy.”

In worksheet3, the students were asked explicitly to write a specific function and to use it in solving the set of tasks given in this worksheet. All the students, with no exception, wrote the function properly and used it in solving the three questions.

When they were asked if they had faced any difficulty writing the function or using it, they all answered with a no. When we further asked them why, unlike in the previous two worksheets, in this one they had wrote and used a function for the common functionality, they explained that it was because they were asked to do so.

Trying to make sense of the observation that students do not take advantage of functions and reuse, despite their proven knowledge and capability to do so, we mapped their explanation quotes to the four cognitive psychological concepts according to the guidelines presented in Table 1. The mapping is presented in Table 2.

Table 1. Preliminary guidelines for mapping explanations and cognitive concepts
Table 2. Theory and related quotes

This demonstration of mapping students’ explanations to the cognitive concepts presents some promise toward an understanding of the different sources leading to the avoidance of using functions. The next step of the research will involve a higher-volume data collection to allow for a more quantitative investigation and generalization of the results. In addition, since students’ explanations do not necessarily accurately reflect their actual thinking processes, we plan to use the think-aloud protocol as a complementary method in the research in order to mitigate this threat.

6 Discussion and Future Work

The pilot study included a small number of participants, all belonging to the same school. The full study will include 12th grade students from four high schools, with the participation of about 30 students from each school. The schools will be of different levels, different teaching languages, and different populations: two private schools and two public ones, with Arabic or Hebrew as teaching languages. These settings are designed so to improve the external validity of the findings.

As a result of this research we hope to expend our understanding on the underlying cognitive processes that lead to the under-usage of functions. Such understanding may lay the foundations for developing means for promoting functions’ use, by overcome the identified barriers for using functions. We will also provide a set of guidelines for mapping given behavior to cognitive states possibly triggering this behavior. These guidelines could be used in the context of function usage in programming specifically, or generally when investigating any under-used tool or information that cannot be explained by the investigated individuals’ lack of knowledge.