3. Program Comprehension and Roles of Variables, a Theoret-
3.3 The Link Between RoV and PC
RoV were introduced as a concept to help novices learn programming. Al- though some work on RoV has been linked to theoretical PC research (e.g., Kuittinen and Sajaniemi’s study [55] draws on Pennington’s work [70]), the author is not aware of any studies about further explicit connection between the two, nor further application of RoV to theoretical PC. Auto- matic role detection tools, such as [9], [29] and [31] can correspondingly be considered as related to practical PC research field. In this section, we discuss how RoV can serve as beacons in PC.
In the previous section, we presented the definition of critical lines and plan-like/unplan-like programs as introduced by Soloway and Ehrlich [91].
Figure 3.2 shows the two programs in Algol language which Soloway and Ehrlich used in their study on PC [91]. The two programs are essentially identical except for lines 5 and 9. The Alpha program (on the left side of the figure) is a maximum search plan and the Beta program (on the right side) is a minimum search plan. In the study, these programs were shown to expert programmers (41 subjects) three times (each time for 20 seconds). On the first trial, the programmers were asked to recall the program lines verbatim as much as they could. On the second and third
Figure 3.2.Plan-like and unplan-like programs used in Soloway and Ehrlich PC study [91]
trials, the programmers were asked to correct or complete their recall of the previous trial. The corrections/additions were made using different color pencil each time which made it possible to track the changes carried out on each trial. The programmers were expected to recall the Alpha program earlier, since it is a plan-like program. In the Beta program, the variable name (max) does not reflect its function, which is a minimum search function. Therefore, the program violates the discourse rule of using proper variables names and thus is considered as an unplan-like program. In their study, Soloway and Ehrlich focused on lines 5 and 9, as they are the critical lines of these programs. The results showed that the programmers recalled significantly more critical lines earlier from the Alpha program than the Beta program. The conclusion was that plan-like programs help programmers in the PC task and that critical lines are important in the process.
Roughly speaking, line 9 in Figure 3.2 and lines 4 and 5 in Figure 3.1 are identical. They both make a comparison between the currently encoun- tered number and the minimum/maximum value of an array of numbers encountered so far. They then store the value of the current number into the variable holding the minimum/maximum value, if it is smaller/larger than the current value of that variable. As illustrated in Figure 3.1, vari- ableminin line 5 has the most-wanted holder role. Therefore, since line 9 in Figure 3.2 is a critical line, most-wanted holder role can also be con- sidered as a critical line (or a beacon) in a search plan. In addition, as discussed above, Brooks [10] regards the presence of a swap operation as a beacon in sorting functions. Swap operations typically include a temporary role and thus this role can be regarded as part of the beacon in the example of Figure 3.1. As we will discuss in this thesis, RoV have an important part in our method in automatic recognition of algorithms. Specifically, for example, the presence of the most-wanted holder role is a strong indicator
(i.e., beacon) in recognizing Selection sort algorithm implementations.
As discussed in Chapter 2, in a study on effects of teaching RoV in elementary programming courses Kuittinen and Sajaniemi [55] found that “the teaching of roles seems to assist in the adoption of programming strategies related to deep program structures, i.e., use of variables”. This is a clear indication of applicability of RoV in PC. Furthermore, since 11 roles can cover all variables in novice-level programs [85], as a tool to be used in PC, RoV are inclusive and comprehensive as well.
From the above discussion, we hypothesize that RoV can be used in PC tasks as beacons. In the case of AR, we will show it in this thesis. As RoV should first be learned before they can be utilized as beacons, one can argue that roles may place a burden on programmers in PC tasks instead of helping them. However, as Sajaniemi and Navarro argue [84], RoV are tacit knowledge of experts. Thus, for experts, roles are somehow already familiar and do not require a huge effort to be learned. In case of novices, it can be logically concluded from the Sajaniemi’s and Navarro’s argument, that novices will (tacitly) adopt RoV, just like other programming skills, as they gain more experience in programming and become experts. It should be noted that, as discussed above, the exact same difference between experts and novices applies with regard to other elements of PC models as well, such as schemas, beacons, general programming knowledge and other elements of programmers’ knowledge base.