<<

The Usage of Pointers, Arrays, and Structures

James Daly December 9, 2012

1 Introduction

In 1968, the Association for Machinery (ACM) proposed a sequence of eight courses that would provide the core of the science curriculum[3]. While their recommendations have changed signif- icantly over the years, their recommendations continue to influence how computer science is taught to this day. In particular, “CS1” is still used to refer to the introductory computer science course and “CS2” to the data structures course. The CS1 course typically covers such topics as basic language syntax, conditionals, looping, structures and objects, arrays, and pointers. Pointers are often considered to be one of the hardest concepts for novice programmers to understand and are usually one of their first stumbling blocks [8]. Pointers are also one of the foundations of the field and form the basis for most of the abstract data structures (ADS) that are traditionally taught during CS2. Without understanding pointers, students will not be able to understand the ADS or many other of the areas of the field. In hindsight, it should come as no surprise that many students find pointers very difficult. In the C++ programming language, pointers have no fewer than three operators associated with them: ”*”, the dereference operator; ”&”, the reference operator; and ”->”, the dereference and access operator. The fact that the asterisk is also used to declare a pointer, but it is the ampersand that is used to create one from an existing object probably does not help to alleviate confusion. This complicated syntax is one of the reasons that pointers are difficult for novice programmers [15]. This is supported by multiple studies showing that students learning Java (which has simplified and restricted pointer syntax) have an easier time understanding pointers than students who learn C++ [8, 9]. It is unclear from the articles whether such students are having an easier time because they are working with simplified syntax or if it carries over when they begin to learn C++. The addition of pointers also necessitates the addition of memory management. Novice programmers make frequent errors either allocating or deallocating memory [1]. Failing to allocate memory at the right time or to reassign a pointer to a safe value after deleting an object can create a wild pointer. Wild pointers are like time bombs that may crash a program when they are finally accessed. Failure to delete an object when the student should have causes a memory leak which can slowly sap resources as the leaks pile up. Finally, freeing memory that was never allocated (or has already been deallocated) is its own crash-worthy bug. As such, there are so many things that an intro programming student must get right that it is surprising that so many of them do pass the class. Several systems have been proposed to help students identify common mistakes that they may make with pointers [11, 1]. These systems, especially the Dereferee library by Allevato et al. can identify many potential problems like wild pointer accesses and pointer arithmetic making it much easier for students to identify what is wrong with their program. Alleveto believes that this is much more efficient than the common novice strategy of using trace statements to output variable states. While Dereferee can help the students identify what is wrong with their programs, other solutions are needed to help them understand the system well enough to not make the mistakes in the first place.

1 2 Background

In a modern “objects-first” style to teaching, introductory computer science students are quickly taught how to encapsulate primitive data types (such as integers, floating-point numbers, or characters) into custom composite structures (or classes) [6]. These classes group data that is logically related into a single unit. A particular instance of a class is called an object. For example, a Complex data type can be defined that has two values representing the real and imaginary parts of a complex number. When a data type or object is to be passed to a function for processing, this can be done in two ways. In the first way, a copy of the object is made for the receiving function. The function can make modifications to its copy during whatever operations it performs, but the original copy will be unchanged. This is called pass by value semantics. The alternative is to pass to the function the location of the object. This allows the function to make changes that will be reflected in the calling function since it has access to the original object. This is called pass by reference semantics. This idea is closely related to the idea of a pointer. A pointer is a special data type whose value is the memory location of an object. In this case, the pointer is said to reference the other object. By dereferencing the pointer, this object can be read or modified. Another special data type is an array. Arrays are collections of data objects that are stored sequentially in memory. Arrays may be defined by having a pointer to the first object in the array. Other objects in the array can be referenced by adding multiples of the object size to the pointer value to get the location of the other objects. As such, pointers and arrays are almost semantically equivalent. Finally, the presence of pointers and arrays creates the problem of managing memory. It is frequently necessary to allocate new objects on the heap with the new command. These objects must be deallocated at some later date with the delete command or else that memory will be lost (or leaked). However, an object that still needs to be accessed should not be deleted or else a wild pointer will be created. Wild pointers have undefined behavior and may silently cause problems. Additionally, two pointers may both point to the same object and should not both be deleted (since they refer to the same object and each object should be deleted precisely once). As such, the semantics of when to delete an object can easily be nontrivial. Aside from the non-trivialities of properly allocating and deallocating memory, many students find point- ers difficult for other reasons. As mentioned in the introduction, the complicated syntax is one of the confounding factors making pointers difficult to understand [15]. Another author believes that the main reason is that novices often have a weak understanding of variables in general [7]. This suggests that the main problem may be that the students do not completely understand variables and as such are failing to transfer their knowledge to understanding pointers. Additionally, variables are a fairly abstract idea and pointers are another layer of abstraction added on top of this. It is not possible to physically observe the values stored in memory (although a can give a good approximation of it) and the relationships that pointers have to objects is difficult to represent. According to Chi, this makes the concept of pointers much more difficult to learn [5]. Furthermore, it is not sufficient for students must be able to correctly apply pointers. This is a higher level of Bloom’s taxonomy than if they simply had to be able to recall pointer syntax or understand pointer theory. The objective of this project is to explore these difficulties that students have and to determine ways to improve student understanding of pointers and their ability to apply them. After completing the CS1 course, the students should be able to collect data types together into classes and to then instantiate them as objects. They should also be able to acquire and dereference pointers to these objects and to create arrays of them. Additionally, they should be able to tell when to use a pointer and when they should use an object (and by association when to use pass by reference and when to use pass by value). Finally, they should be able to allocate and deallocate objects without leaking memory or creating wild pointers. These skills are necessary for the student to be able to take the CS2 (Abstract Data Structures) and more advanced courses. Finally, the CS1 course should lay the groundwork for the students to be able to independently frame and solve problems. In How People Learn, the authors review several surveys which analyze the differences between novices and experts and found that experts are much better at being able to notice patterns and are better able to use those patterns to solve new problems [10]. Several of the other courses, most notably CS2,

2 are designed for teaching students lots of tools and patterns to use for solving new problems. In contrast, the CS1 course teaches more basic building blocks rather than the more advanced schemata. However, the students should begin to become comfortable with the basics of design.

3 Pre-Assessment

At Michigan State University, computer science students are required to take an introductory Python course before they take the C++ course. As such, they will already have seen many of the above ideas, albeit in a limited form and a different guise. Thus, we will create and administer a pre-assessment to determine how much they recall from their Python class and see how well they can use it to predict the behavior of similar situations in C++. This pre-assessment will not count towards their grade but rather serve as a starting point for the unit. Our pre-assessment will be a Background Knowledge Probe [2] where the students are given several short programs and they have to identify what each of the programs output. This quiz will have two parts to it. The first part will be in Python, which they should have seen before in the earlier class, and they should be able to get most of this part correct. This will test their recall from their previous classes. The second part will be in C++ and they will not be expected to get all of this part correct. This demonstrates ways in which the two languages may be either similar or disparate. Together, they cover the first two levels of Bloom’s Taxonomy: recall and comprehension [4].

3.1 Quiz

# 1) Write the output of the following Python program x = 10 y = x x = 20 print x print y

# 2) Write the output of the following Python program x = 10 y = x y = 20 print x print y

# 3) Write the output of the following Python program x= [10, 20, 30] y = x x [ 1 ] = 25 print x print y

# 4) Write the output of the following Python program x= [10, 20, 30] y = x y [ 1 ] = 20 print x print y

3 # 5) Write the output of the following Python program x= [10, 20, 30] y = x x = [ 1 , 2 , 3 ] print x print y

// 6) Write the output for the following C++ program or tell if it is illegal int x = 1 0 ; int y = x ; x = 2 0 ; cout << x << endl ; cout << y << endl ;

// 7) Write the output for the following C++ program or tell if it is illegal int x = 1 0 ; int y = x ; y = 2 0 ; cout << x << endl ; cout << y << endl ;

// 8) Write the output for the following C++ program or tell if it is illegal int x = 1 0 ; int ∗ y = &x ; x = 2 0 ; cout << x << endl ; cout << ∗y << endl ;

// 9) Write the output for the following C++ program or tell if it is illegal int x = 1 0 ; int ∗ y = &x ; ∗y = 2 0 ; cout << x << endl ; cout << ∗y << endl ;

// 10) Write the output for the following C++ program or tell if it is illegal int x [ ] = {10 , 20 , 30}; int ∗ y = x ; x [ 1 ] = 2 5 ; cout << x [ 0 ] << ” ” << x [ 1 ] << ” ” << x [ 2 ] << endl ; cout << y [ 0 ] << ” ” << y [ 1 ] << ” ” << y [ 2 ] << endl ;

// 11) Write the output for the following C++ program or tell if it is illegal int x [ ] = {10 , 20 , 30}; int ∗ y = x ; y [ 1 ] = 2 5 ; cout << x [ 0 ] << ” ” << x [ 1 ] << ” ” << x [ 2 ] << endl ; cout << y [ 0 ] << ” ” << y [ 1 ] << ” ” << y [ 2 ] << endl ;

4 // 12) Write the output for the following C++ program or tell if it is illegal l i n t x [ ] = {10 , 20 , 30}; int ∗ y = x ; int z [ ] = {1 , 2 , 3 } ; y = z ; cout << x [ 0 ] << ” ” << x [ 1 ] << ” ” << x [ 2 ] << endl ; cout << y [ 0 ] << ” ” << y [ 1 ] << ” ” << y [ 2 ] << endl ; cout << z [ 0 ] << ” ” << z [ 1 ] << ” ” << z [ 2 ] << endl ;

3.2 Answer Key Each of the above problems are scored equally: either 1 if correct and 0 if incorrect (although the score does not count toward their grade). The answers are as follows. 1 . ) 20 10

2 . ) 10 20

3 . ) [ 1 0 , 25 , 3 0 ] [ 1 0 , 25 , 3 0 ]

4 . ) [ 1 0 , 25 , 3 0 ] [ 1 0 , 25 , 3 0 ]

5 . ) [ 1 , 2 , 3 ] [ 1 0 , 20 , 3 0 ]

6 . ) 20 10

7 . ) 10 20

8 . ) 20 20

9 . ) 20 20

5 1 0 . ) 10 25 30 10 25 30

1 1 . ) 10 25 30 10 25 30

1 2 . ) 10 20 30 1 2 3 1 2 3

3.3 Analysis Problems 1-5 are in Python and serve to check what they recall about assignment. The first two problems everyone should get right and demonstrate that there is no connection between the variables themselves after an assignment. Problems 3 and 4 show that if two variables are assigned to the same object, then modifying the object will affect both of them. A student who forgot this (or never learned it) will give different answers for the two problems. Problem 5 then shows that the object reference can be reassigned independent of modifying the object’s fields. This does not act like problems 3 and 4 as some students may assume. Problems 6-12 ask the students to predict how C++ programs will behave. Problems 6 and 7 are basically identical to problems 1 and 2 and behave the same way. They serve to draw a connection between Python and C++. Problems 8 and 9 give them their first exposure to pointers. They may assume these to operate like the earlier problems, but the pointer is linked to the other variable and so the answers are different than the previous problems. The remaining problems serve to introduce arrays and demonstrate how they can be used with pointers. Some students may believe that these assignments may be illegal, but it demonstrates to them that it is allowed.

4 Instruction

Given that one of the objectives for this course is for the students to develop the practical ability to apply the concepts covered in this class, it would be useful for them to have some class time for practicing these skills. To this end, class will be divided into up into lecture time, where they are taught about a new skill, and practicals, where they are given a chance to apply the skill in a short exercise. The activities help to keep the students actively engaged in the class by requiring them to participate. It also allows the instructor the opportunity to see how well the students are learning a topic and give them a chance to correct any misconceptions. [12] During most of these activity sections, the students will utilize pair programming to collaboratively accomplish a task. Pair programming comes from eXtreme Programming. In it, two programmers collabo- ratively work side by side on the same task. One of them acts as the driver and is in charge of the coding. The other person is the navigator and watches for defects, looks up resources, and thinking alternative methods. The two normally switch roles periodically. Students will be given an overview of pair programming on the first day of class after being given the syllabus. As seen in [14], there have been several studies documenting the benefits to using pair programming in undergraduate programming classes. They found that each individual spends 42.5% less time on development time and a 15% reduction in the number of defects in the end result. Students are also usually happier with the experience than with programming alone. It also reduces student reliance on the instructor since usually one student knows what the other does not.

6 Some students learn well from lectures while others learn best by doing. By placing the two back to back, the students benefit by having both modalities and being able to connect them. Additionally, by having them collaborate on assignments, they can benefit from other students who may learn better in other ways. Pointers and arrays will get two 80 minute class periods about four weeks into the semester. During the first session, they will be introduced to arrays, pointers, and memory allocation. The second will cover memory management issues and calling syntax. A typical session will involve a 3-5 minutes to review the previous session, three practical-lecture pairs with approximately 8-10 minutes for the practical activity and 10-12 minutes for the lecture, and approximately 5 minutes of summary and review at the end. As suggested in [12], breaking up lectures with activities helps to reinvigorate students and prevent them from losing focus. A chart showing how this works for the first session can be seen in Table 1. During this unit, we will use a simple list structure as a driving example. Most of the lessons in this unit will be presented in the framework of incorporating them into the list. Furthermore, they will be presented with the problem first and the new tool afterwards. This gives them the opportunity to meta-cognitively assess what they know and determine what they need to learn. As part of the implementation, the practical activity is broken up into two sections. In the first section, they do most of the problem setup and discover the problem they need solving. After they learn the solution to their problem, they implement the solution. This is subsequently followed by another setup section, allowing students to borrow time from one or the other.

4.1 The First Session The first few minutes of class are used for reviewing the prior session (data abstraction) and clearing up any questions the students may have. After this, the students will be given the pre-assessment detailed in Section 3. This assessment should take about 5 minutes. Next, we will present the driving example. We wish to create a simple list that will store names entered by the user. Later, we will want to be able to change numbers in the list and print them back to the user. After a brief explanation, they will have a few minutes to begin their implementation. Some of them may try to create a separate named variable for every item in the list. It should become readily apparent that this is an infeasible solution. With this, we can present the first solution: arrays. Here, we will show how to stack-allocate arrays and how to access the items in an array. After the standard analogy of a series of pigeonholes that each contain an object, they will be able to complete the first exercise. The second exercise is to modify elements of the list. After the list has been seeded with values, the client (not the list itself) will iterate through all of the items and append the index number to all of the names within the list. This is doable because strings in C++ are mutable objects. However, they will find that the strings returned from the list are clones of the original. Thus, they must be passed back to the list for the changes to stick. The students should be wondering if there is an easier way to do this. Indeed there is. The next section discusses pointer basics. We will extend our pigeonhole analogy by saying that if objects are like the objects within each of the holes, then a pointer is the numbering that allows you to find the proper hole. Furthermore, arrays and pointers are largely equivalent; there is little difference in saying you want the seventh hole from this one, or that one in particular. We also introduce the & operator, which gets a pointer to a variable, and the ∗ operator, which gets the variable from a pointer. This will allow them to create a new accessor method that returns a pointer to the string rather than a copy of it, allowing them to complete the second assignment. We will also review the pre-assessment here as comparing this will help them compare one of the primary differences between Python and C++ and they should now be able to give the correct answers themselves. The third exercise is to convert the list so that it has variable capacity instead of fixed capacity. The user will enter a number and then the list will accept that many names from the user. However, their array is stack-allocated and thus the array must be of fixed size; they will get a compile-time error if they try to initialize the array to variable length. Variable-length arrays must be heap-allocated with the new command. This will allow them to create an array of any size at run-time. Here, we will only give a brief overview of the differences; this is the domain

7 Time Activity 0-5 min Review of data abstraction 5-10 min Pre-assessment 10-15 min Beginning the list exercise 15-25 min Arrays theory and syntax 25-35 min Adding arrays to the list List modification exercise 35-45 min Pointer theory and syntax 45-55 min Pointer return value Variable capacity exercise 55-65 min Memory allocation and the new command 65-70 min Finishing variable-sized list 70-75 min Review of the day 75-80 min Starting the homework and flex time

Table 1: Time chart for the first session of an architecture or operating systems course. This will allow them to complete the third exercise. The remainder of the class time will be spent allowing the students to complete the exercises so far, reviewing what we covered in class today, and if time permits, to get started on their homework. The homework is covered further in Section 4.3 and is shared across the two sessions (they will not be expected to have completed it before the next session).

4.2 The Second Session The second session will have a similar overall structure to the first session and will cover destructors, memory issues, the rule of three, and pass by reference syntax. The first three deal with the dangers and pitfalls of using pointers and heap-allocated memory. The second session begins with a review of the first session. This will then proceed into a discussion about what happens to the objects during the lifetime of their program. They will be given a few minutes to work with their partners to plot out the life cycles of each of the objects used by their program from the first session. From this activity, they should be able to determine that the array is never deallocated but is still floating around when their program ends. In Python, they did not need to manually deallocate objects; a special process called the garbage collector keeps track of which objects are no longer reachable and deletes them. C++ does not have this functionality. They need to use the delete command to deallocate any memory that they have allocated. This can be done in the special destructor method to clean up any memory utilized by the object. Naturally, after learning about destructors and the delete method, they will be given the opportunity to implement them in their list object. This then proceeds into their next activity; to make a method that iterates through and prints all of the names. They should find that the method utilizes a copy of the list that uses the same array. This copy deletes the array when the method terminates. When the original deletes the array a second time, their program crashes. This leads into the rule of three: any object that has a destructor also needs to have a copy constructor and an assignment operator. This leads to two possible solutions; either they can create a copy of the array so each list has their own version, or they can make these methods private so that the object cannot be copied. By utilizing the second solution, they can prevent the crash bug, but they will also find that it prevents them from passing the list to their method. Their are two solutions to their problem. The first, which they can already do, is to pass a pointer to the list to the method instead of the list itself. However, they may find dereferencing the pointer to be slightly awkward. The alternative, simpler, solution is to utilize pass-by-reference semantics. This allows them to pass in the original list without creating a copy.

8 After allowing a few minutes to finish up their list program, we will spend a few minutes reviewing what we covered in class. Any remaining time can be used for them to begin their homework.

4.3 Homework They will also have a homework assignment for these two sessions. This assignment is to ensure that they have everything they need in order to be able to work on the project in the post-assessment. They will be encouraged to do the homework with their pair programming partner. The first part of the homework is a tutorial covering how to get DeReferee [1] and the QT GUI library installed and running. The DeReferee library will help the students by identifying several common types of memory errors, allowing them to identify and fix them earlier. The GUI tutorial will cover several of the drawing functions, window controls, and event handlers. The original aspect that they will do is to read a file containing information for several shapes and to draw them. They can then turn in their own file to create their own image with their assignment. They will be able to reuse part of this assignment for the post-assessment project. In particular, the menus and event handlers should be set up from the tutorial.

5 Post-assessment

After the unit is completed, it will be important to test their understanding of the material, especially pointers and arrays. Since we cannot measure understanding directly[13], we instead measure the most important things that someone who understands these areas should be able to do. In this case, it is important that the student be able to correctly apply these concepts. As such, the post-assessment will be a programming project that will require them to use most of the skills covered. This project will be to recreate the Minesweeper game which is included in Windows and many distributions. In this game, an m × n grid is shown to the player, k of which contain hidden mines. When the player clicks on one of the squares one of two things will happen. If it contains a mine, then it explodes and the player loses the game. The location of all of the mines is then revealed. Otherwise, a number is shown revealing how many of the adjacent spots (diagonals included) contain mines. The player may alternatively right-click on a square to flag it as containing a mine without examining the square. When only the k squares containing mines remain unvisited, the mines are revealed and the player wins the game. Since this project involves graphical elements that are not actually part of the material to be tested on, the students will first be given a tutorial assignment as part of their homework (shown in Section 4.3 to create most of the UI elements of the game. This will allow them to start with the window frame, menu, mines remaining counter, and restart button all drawn and the event handlers already in place. Example images that the student can use for drawing the various elements will be included with the tutorial. They will still need to implement most of the game logic including the internal minefield representation (which will require either a two-dimensional array or a multiplexed one-dimensional array), the state of each cell, and counting how many unflagged mines remain. The assignment that the students get is included in Section 5.1 while the rubric for grading their project is in Section 5.2

5.1 Project Handout Beginning with the work that you did for the previous homework assignment, you are going to recreate the game Minesweeper. In this game, an m × n grid is displayed. k of these cells contain mines, but the contents of the cells is hidden from the player. By clicking on a cell, the contents will be revealed to the player. If it is a mine, it detonates and the player loses the game. The location of all of the mines is then revealed. Otherwise, the number of adjacent cells (including diagonals) is revealed. By right-clicking on the cell instead of clicking on it, a flag is placed without revealing the actual contents of the cell. This flag represents a

9 cell which the player believes to contain a mine. When only cells containing mines are left unexamined (or flagged), the game is over and the player wins. Your program must display a grid with the behavior mentioned above including different icons for visited, unvisited, and flagged mines. It should include a counter for the number of unflagged mines remaining. This counter should decrement by 1 whenever the player sets a flag. It must detect when the game is won or lost and alert the player to the fact and prevent further board manipulation when the game is over. The player should be able to start a new game, either through a button or through the menu. It should support multiple board sizes through menu options. You do not have to include either the timer or the flood reveal functions included with most versions of the game. You should include a readme file explaining the major parts of your program and how they interact. You may use this to justify any unusual design decisions that you may have made.

5.2 Rubric Criteria Excellent Fair Poor Initialization 10 pts Board randomly generated Fixed board 10 pts New game resets board No reset Display 10 pts Icons draw for all states cor- Only some states are repre- Board does not draw rectly sented 5 pts Game identifies end and Game identifies end but Game doesn’t identify that locks continues it is over 5 pts Correct cell responds when Wrong cell responds Game unresponsive clicked 10 pts Correct number displayed Edge cells display incorrect Wrong or no numbers shown numbers Memory 5 pts All memory deallocated Some memory leaks Wild pointer access or dou- properly ble free 5 pts Multiple board sizes One board size 5 pts Board is heap-allocated Board is stack-allocated 5 pts Pointers to images are Images drawn programati- Each tile has its own image shared cally copy Compiling 5 pts No errors or warnings Some warnings Some errors Design 5 pts The code is easy to read Code only readable by Code is difficult to read someone familiar with the project 5 pts Code divided into reason- Some functions or classes do Code structure non-existent able sections too much Writing 5 pts Consistent coding style Mostly consistent style Inconsistent style 5 pts No spelling errors Some spelling errors Many spelling errors 5 pts Named constants or enums Magic numbers commented Magic numbers are used used

10 5.3 Analysis The post-assessment focuses on the apply layer of Bloom’s taxonomy[4]. The emphasis is on their ability to put what they have learned into practice. The student will probably create a class to represent the contents of a cell and its current state and may need pointers to objects representing these cells. The requirement for multiple board sizes ensures that the board must be heap-allocated, thus requiring that they do memory allocation and deallocation. A portion of their grade is based on their design and writing ability. As mentioned in Section 2, the students are not yet expected to have the planning and design skills that an expert would have. As such, very few points are given for their design process which can be claimed by justifying their overall design in their readme file. Rather, most of these points are for being able to write in a manner that allows others to understand what they are trying to do.

6 Conclusion

We have outlined a unit on pointers, arrays, and memory management for a CS1 type class. Pointers are usually considered one of the hardest topics for introductory programming students to grasp [8]. We propose a style where students collaborate together to apply new skills immediately after learning them. This allows and encourages one student to help the other when one of them does not fully understand one of the concepts [14]. Additionally, between the extra pair of eyes and the DeReferee library [1], the students should have a much easier time identifying and fixing their bugs, especially the very common memory bugs that often plague introductory programming projects. Finally, combining the lecture and practical exercises in this manner should better allow them to visualize these difficult concepts and understand how they work and why they need them. All together, this should reduce frustration and improve retention amongst the students.

References

[1] Anthony Allevato, Stephen H. Edwards, and Manuel A. P´erez-Qui˜nones.Dereferee: exploring pointer mismanagement in student code. SIGCSE Bull., 41(1):173–177, March 2009. [2] Thomas Angelo and Patricia Cross. Classroom Assessment Techniques: A Handbook for Teachers. Jossey-Bass, 2nd edition, 1993.

[3] William F. Atchison, Samuel D. Conte, John W. Hamblen, Thomas E. Hull, Thomas A. Keenan, William B. Kehl, Edward J. McCluskey, Silvio O. Navarro, Werner C. Rheinboldt, Earl J. Schweppe, William Viavant, and David M. Young, Jr. Curriculum 68: Recommendations for academic programs in computer science: a report of the acm curriculum committee on computer science. Commun. ACM, 11(3):151–197, March 1968.

[4] Benjamin Bloom. Taxonomy of Educational Objectives. Addison Wesley, 1984. [5] Michelene T. H. Chi. Commonsense conceptions of emergent processes: Why some misconceptions are robust. Journal of the Learning Sciences, 14:161–199, 2005. [6] Stephen Cooper, Wanda Dann, and Randy Pausch. Teaching objects-first in introductory computer sci- ence. In Proceedings of the 34th SIGCSE technical symposium on Computer science education, SIGCSE ’03, pages 191–195, New York, NY, USA, 2003. ACM.

[7] Ted Jensen. A tutorial on pointers and arrays in c. http://pweb.netcom.com/~tjensen/ptr/. [8] Essi Lahtinen, Kirsti Ala-Mutka, and Hannu-Matti J¨arvinen. A study of the difficulties of novice programmers. SIGCSE Bull., 37(3):14–18, June 2005.

11 [9] Iain Milne and Glenn Rowe. Difficulties in learning and teaching programmingviews of students and tutors. Education and Information Technologies, 7:55–66, 2002. 10.1023/A:1015362608943. [10] Committee on Developments in the Science of Learning with additional material from the Committee on Learning Research and National Research Council Educational Practice. How People Learn: Brain, Mind, Experience, and School: Expanded Edition. The National Academies Press, 2000.

[11] Scott M. Pike, Bruce W. Weide, and Joseph E. Hollingsworth. Checkmate: cornering c++ dynamic memory errors with checked pointers. SIGCSE Bull., 32(1):352–356, March 2000. [12] Karl A. Smith, Sheri D. Sheppard, David W. Johnson, and Roger T. Johnson. Pedagogies of Engage- ment: Classroom-Based Practices. Journal of Engineering Education, pages 1–15, January 2005.

[13] Grant Wiggens and Jay McTighe. Understanding by Design. Association for Supervision and Curriculum Development. [14] Laurie Williams and Richard L. Upchurch. In support of student pair-programming. SIGCSE Bull., 33(1):327–331, February 2001.

[15] C. Zhao and F. Moinian. Teaching pointers in c/c++ to cs freshman students. http://cerc.wvu.edu/ download/WORLDCOMP%2711/2011%20CD%20papers/FEC2888.pdf, 2011.

12