Int. J. Teaching and Case Studies, Vol. 2, No. 1, 2009
41
A proposal for teaching Object-Oriented Programming to undergraduate students Stelios Xinogalos Department of Technology Management, University of Macedonia, Loggou-Tourpali, 59200 Naousa, Greece E-mail:
[email protected] Abstract: Various teaching approaches have been proposed for teaching Object-Oriented Programming (OOP) to novices. In this paper we present the results of studying students’ conceptual grasp of OOP concepts in two distinct teachings based on the educational programming environments BlueJ and objectKarel. Also, students’ replies regarding the effectiveness of objectKarel as a medium of introducing novices to OOP and preparing them for a transition to a conventional OOP language are presented. The main contribution of this paper relates to a new proposal for teaching OOP to undergraduate students, which is based on the combined use of objectKarel and BlueJ. Keywords: OOP; object-oriented programming; educational programming environments; programming microworlds; teaching programming. Reference to this paper should be made as follows: Xinogalos, S. (2009) ‘A proposal for teaching Object-Oriented Programming to undergraduate students’, Int. J. Teaching and Case Studies, Vol. 2, No. 1, pp.41–55. Biographical notes: Stelios Xinogalos holds a PhD in ‘Educational Technology – Didactics of Informatics’ from the University of Macedonia. He teaches the courses ‘Computer Programming’ and ‘Object-Oriented Design and Programming’ at the Technology Management Department, University of Macedonia, Greece. His research focuses on object-oriented programming, educational programming environments and didactics of programming.
1
Introduction
Teaching Object-Oriented Programming (OOP) to novices is widely known to be quite problematic. Students might be able to write a piece of code in an OOP language, usually Java, but their conceptual grasp of object-oriented concepts seems to be limited. This is confirmed by the various misconceptions, erroneous student-constructed rules and errors recorded in the literature (Carter and Fowler, 1998; Fleury, 2000, 2001; Holland et al., 1997; Hristova et al., 2003; Topor, 2006). This leads to poor implementation of object-oriented concepts and inability to take advantage of the strengths of OOP. Various teaching approaches have been proposed for making the teaching and learning of OOP concepts easier and more effective, and even criteria for selecting a programming language for an introductory programming course have been
Copyright © 2009 Inderscience Enterprises Ltd.
42
S. Xinogalos
proposed (Parker et al., 2006). The most important teaching approaches are described briefly in the following paragraphs. Holland et al. (1997) suggest the presentation of examples and the assignment of exercises especially designed for avoiding misconceptions that have been recorded and cannot be easily shifted once acquired by students. For example, to avoid the misconception that ‘object’ and ‘class’ are the same concept, instructors should use examples where several instances of each class are used. Proulx et al. (2002) state that teaching should begin with the concept of objects, which should have a noticeable behaviour and should interact with other objects. The familiarisation of students with the main concepts of OOP is accomplished through a series of labs and lectures that are based on using GUIs developed by Proulx et al. (2002) in Java. Although some researchers (Kölling et al., 2003) are opposite with the use of GUIs as a medium of teaching object-oriented concepts, Proulx et al. (2002) consider their use necessary. Nevison and Wells (2003) believe that teaching OOP should begin with teaching objects, as most instructors do. However, to present interacting objects the use of difficult/complex examples is required. Nevison and Wells suggest the use of case studies that give the chance to present complex examples at the beginning of an introductory programming course, as well as the ability to adopt an object-oriented approach to solve problems. The choice of a case study must be done carefully, which means that the complexity of the system that the case study describes favours the presentation of object-oriented concepts and the implementation of simple programs that can be used in an introductory programming course. Also, the case studies that are going to be used must allow the gradual presentation of concepts (one concept each time) through the development of a series of programs of increasing complexity. Kölling et al. (2003) state that teaching OOP is difficult because of the lack of appropriate tools and teaching experience for the specific programming paradigm. The most important problems of the environments that are used for teaching OOP are: •
the environment is not object-oriented
•
the environment is complex
•
the environment focuses on the development of GUIs and not on object-orientation.
To avoid these problems Kölling et al. (2003) developed the educational programming environment BlueJ (http://www.bluej.org) that uses Java as a programming language. When a student opens a project she/he is presented with a simplified UML diagram that visualises the structure of the application. The student begins with a predefined set of classes, creates objects and invokes the available methods, to study the objects’ behaviour. The predefined classes are used for presenting the syntax of Java. Next, students extend existing classes by implementing or adding their own methods. The next step is the definition of classes by students in the context of an existing project. Finally, students are separated into groups and implement an application. Programming microworlds are a special kind of educational programming environments. What differentiates them is the fact that they use an educational programming language or a subset of a conventional language. Programming microworlds are designed and implemented entirely for didactic purposes and as a consequence they share some common characteristics:
A proposal for teaching Object-Oriented Programming •
they are, usually, based on existing physical metaphors and use an educational programming language
•
they constitute integrated programming environments that are characterised by usability and incorporate various forms of educational technology for supporting students, such as software visualisation technologies
•
the problems solved are, usually, everyday problems.
43
Teaching with programming microworlds focuses on concepts, and not on the syntax of the language. However, in some cases the programming language used constitutes a subset of a conventional programming language, and learning its syntax is part of the didactic process. The majority of the microworlds that have been developed for an introduction to OOP is based on Karel the Robot (Pattis et al., 1995) and Karel++ (Bergin et al., 1997). Such microworlds are Karel J. Robot (http://csis.pace.edu), JKarelRobot (Buck and Stucki, 2000), Jeroo (Sanders and Dorn, 2003) and objectKarel (Xinogalos, 2002; Xinogalos et al., 2006). Another popular microworld is Alice (Cooper et al., 2000), which is used for implementing virtual microworlds with 3D objects. In this paper, we present the results of teaching OOP with the educational programming environment of BlueJ (Kölling et al., 2003) and the programming microworld of objectKarel (Xinogalos et al., 2006). First, the main features of both the environments and the associated teachings are presented. This presentation is followed by a description of the goals, the design and some important factors of the empirical study. Then the results that refer to the students’ conceptual grasp of OOP concepts in both environments are presented in conjunction. Also, the answers of the objectKarel group in a questionnaire regarding the effectiveness of the relevant teaching are presented. Finally, a proposal for teaching OOP to undergraduate students is presented based on the conclusions drawn from the empirical study.
2
The educational programming environments BlueJ and objectKarel
2.1 The main features of BlueJ In the integrated programming environment of BlueJ, objects and classes are presented in a visual way, while the structure of an application is presented with the use of a simplified form of a UML diagram. Students can use the interactive interface of BlueJ for creating objects and invoking their methods. A method is invoked by right-clicking on the visual depiction of an object and then selecting the method name from the pop-up menu that appears. Students can also inspect the state of the objects that they have created. This feature gives students the chance to watch the state of instance variables. Furthermore, this feature gives instructors the chance to delay the presentation of other interface technologies and support a pure objects-first approach. The editor supports limited colouring of source code (syntax highlighting), display of line numbers and brackets matching. The source code of each class is presented in a separate window. In the case of syntax errors, they are presented in the bottom of the window. BlueJ also provides a visual debugger that allows the insertion of breakpoints
44
S. Xinogalos
and step-by-step execution. When the user invokes a method where a breakpoint has been inserted the debugger window appears automatically. This window consists of the threads, call sequence, static variables, instance variables and local variables panels.
2.2 The main features of objectKarel objectKarel (Xinogalos, 2002; Xinogalos et al., 2006) is based on Karel++ (Bergin et al., 1997) and uses a programming language closely related to C++ and Java. objectKarel (2005) incorporates a series of lessons and activities for familiarising students with OOP concepts before they are asked to implement them (Xinogalos and Satratzemi, 2005). Students use a structure editor for developing programs, so as to avoid focusing on the syntax details of the programming language. The structure editor has the form of a menu that is automatically updated when changes are made to classes, and dialog boxes. The errors that can arise are very few and they are presented at the bottom of the main window, while there is the ability of interaction between error messages and the corresponding lines of source code. Students can run a program, trace through it with a speed defined by them or execute it step by step. Also, objectKarel incorporates the technology of explanatory visualisation, which is the presentation of explanatory messages in natural language about the semantics of the current statement. The actors of the microworld are robots that live in a world consisting of horizontal streets and vertical avenues, wall sections and beepers, which are small plastic cones that emit a ‘beep’ noise. The class Primitive_Robot is the base class provided and contains: •
the fields street (street number), avenue (avenue number), direction (the direction a robot is facing) and numOfBeepers (number of beepers in the robot’s bag)
•
the methods move (moves the robot to the next corner if front is clear), turnLeft (the robot turns left 90°), putBeeper (the robot takes a beeper from its bag and leaves it to its corner) and pickBeeper (the robot takes a beeper from its corner and places it to its bag).
Also, a class named Robot that extends the Primitive_Robot class is available. This class defines boolean methods, such as frontIsClear, nextToABeeper and anyBeepersInBeeperBag, that give robots the ability to check their own state and the state of the microworld.
3
Teaching OOP concepts with BlueJ and objectKarel
BlueJ and objectKarel were used for teaching OOP concepts to undergraduate students. The BlueJ group was taught a relatively conventional introduction to OOP, while the objectKarel group was taught a seminar to OOP. Both teachings were organised by the same research team with a focus on OOP concepts and were entirely taught by the same instructor. Next, we describe briefly the characteristics of the two teachings.
3.1 Teaching OOP concepts with BlueJ BlueJ and the series of lessons suggested by Barnes and Kölling at their book “Objects First with Java: A practical introduction using BlueJ” (Barnes and Kölling, 2004)
A proposal for teaching Object-Oriented Programming
45
were used for teaching the compulsory one-semester course “Object-oriented Design and Programming” at the department of Technology Management, University of Macedonia, Greece. The aim of the course is for the students to comprehend and be able to use basic concepts of OOP. The course is taught in the 3rd semester, while students are taught the main concepts of programming in the 2nd semester with C as a programming language. In the final exams of the 2nd semester course, a high failure rate was recorded for the specific group of students. The course of the 3rd semester consisted of a weekly 2 h theory session and a weekly 2 h laboratory session. Approximately 45 students attended the 11 lessons (lecture and laboratory) that were given. In each lecture, the instructor presented the corresponding concepts with the use of slides. Occasionally, the BlueJ environment was used for creating objects, invoking their methods and presenting/discussing their result with students. All the concepts were presented in the context of the projects that accompany the book of Barnes and Kölling (2004). Some of these projects consist of a large number (for students) of classes, but not all of them were presented/studied. Specifically, for some of the classes only their role or part of their interface was presented to students and not their implementation. Copies of the projects’ source code or excerpts of the source code (commented by the instructor), UML class diagrams and object diagrams were given to students to assist them in understanding the presented concepts and keeping notes for parts of the source code they faced difficulties with. Each laboratory session started with a brief summary of the concepts presented at the corresponding lecture. Next, students solved in cooperation with the instructor an assignment, which aimed at using the taught concepts. A video projector was used for presenting and discussing the various solutions suggested by students and also their syntax, logic and semantic errors. Finally, students carried out various assignments based on the projects presented at the book. In the context of these assignments, students had to modify/extend the given projects by adding fields, constructors and methods to existing classes, and at some cases defining new classes. Students developed projects from scratch only at the last lesson.
3.2 Teaching OOP concepts with objectKarel objectKarel was used for teaching the main concepts of OOP to undergraduate students from the department of Applied Informatics, University of Macedonia, Greece. The students who participated in the empirical study had attended the 1st semester compulsory course ‘Programming’, which is based on the procedural programming paradigm and uses Pascal as the programming language, and they had all failed in the exams. Nineteen students attended the five lessons that were given. All the lessons were carried out at the laboratory, and the programming environment was used as the medium of instruction – occasionally the blackboard was used too. The lessons took place weekly, and their duration was 2 h each. In each one of the lessons, we used the theory of the e-lessons that are incorporated in the programming environment to teach the corresponding concepts. Next, students used the activities that are incorporated in the programming environment, and in some cases existing programs, so as to assimilate the concepts and become familiar with the features of the programming environment. Finally, the students in groups of two developed one or two programs without help from the instructor. Students were not assigned any homework.
46
4
S. Xinogalos
The design of the empirical study
Both teachings, although different, shared the same goal: introducing students to the main concepts of OOP. To study students’ conceptual grasp of OOP concepts the two groups of students took a common test especially designed for this purpose. In the next paragraphs, we briefly describe the goals of the empirical study, the methodology used, as well as some important factors that must be taken into account when reading the results.
4.1 The goals This empirical study had two goals: •
The first one was to study to what degree difficulties and misconceptions regarding the teaching of OOP that have been recorded in the literature appear in the context of teachings based on educational programming environments, such as BlueJ and objectKarel.
•
The second one was to study if there is significant difference in students’ conceptual grasp of OOP concepts when taught with BlueJ and objectKarel. In other words, our goal was to compare the didactic effectiveness of two environments that are typical representatives of an educational programming environment based on Java and a programming microworld based on the Karel robot.
4.2 The methodology To achieve the goals of the empirical study we used a test that was answered by both groups at the end of the lessons. Students answered the test without having made any special preparation, revision or study – as is usually the case in periods of exams, since it was given in the context of an activity and not in the context of the final exams. Thirty four students of the BlueJ group and 19 students of the objectKarel group took this test. Furthermore, the objectKarel group answered a questionnaire, which aimed at recording students’ view regarding the use of objectKarel as a medium of introducing students to OOP and preparing them for a transition to a conventional OOP language. The test consisted of six open type questions specially designed to test students’ conceptual grasp of basic OOP concepts – objects, classes, multilevel inheritance, polymorphism and overriding – and not their code cutting prowess. The last two questions tested students’ ability to extract information regarding these basic concepts from excerpts of code. Owing to the fact that the last two questions referred to the metaphor used on the microworld of Karel++, the BlueJ group was given – besides the source code in Java – a description of the microworld similar to the one presented at the end of Section 2.2. Furthermore, the BlueJ group was given twice the time of the objectKarel group (2 h instead of 1) for answering the test. In addition, they had the chance to ask for help regarding the metaphor, although it is quite clear and easy to understand.
A proposal for teaching Object-Oriented Programming
47
4.3 Important factors Prior to presenting the results, we must stress out some important factors, so as to have a precise picture of these results. •
The BlueJ environment constitutes an educational programming environment based on Java that is designed for helping students in comprehending basic concepts of OOP, but is also a relatively open environment that practically allows the solution of any problem. On the other hand, the objectKarel environment constitutes a didactically minimalistic microworld, since it refers to virtual robots moving on a world of crisscrossing streets and avenues and can be used only for the teaching of basic OOP concepts.
•
The lessons carried out with the environment of BlueJ were 11 (2 h lecture and 2 h lab each) and the total duration 44 h, while the lessons carried out with the environment of objectΚarel were 5 (2 h each) and the total duration 10 h. Their content was at a high degree analogous (objects, classes, inheritance, polymorphism, overriding), but not the same. However, the basic concepts examined were taught in the same number of lessons in both teachings, as shown in Table 1.
•
The audience of the two series of lessons was not the same, neither in number nor in background. The students who participated in the lessons with objectKarel were volunteer students that had attended a compulsory “Introduction to Imperative Programming” course based on Pascal at the Department of Applied Informatics, and had all failed in the exams. On the contrast, teaching OOP with BlueJ took place in the context of a typical teaching at the 3rd semester at the Department of Technology Management. The students of the BlueJ group had also attended a compulsory “Introduction to Imperative Programming” course based on C with a high failure rate.
•
Both teachings were designed by the same research team with the aim of focusing on OOP concepts and the instructor was a member of this team.
•
The selection of questions and problems that were suggested to students was made having as criteria the concepts of OOP that seem to represent the main sources of difficulties for novices (Carter and Fowler, 1998; Fleury, 2000; Holland et al., 1997; Hristova et al., 2003). These concepts are objects, classes, inheritance, polymorphism and overriding.
Table 1
Organisation of lessons in BlueJ and objectKarel
Concepts
BlueJ
objectKarel
Objects and classes
1st lesson (4 h)
1st lesson (2 h)
Inheritance
8th lesson (4 h)
2nd lesson (2 h)
Polymorphism and overriding
9th lesson (4 h)
3rd lesson (2 h)
48
5
S. Xinogalos
The results of the empirical study
5.1 Analysis of test results Next, we present the results of the test. For each question that is examined comparatively in the two environments, we remind some basic findings recorded in the literature and present the relevant results from our study. Question 1: Are the concepts ‘class’ and ‘object’ identical? Justify your answer. Literature review. Experience has shown that students often confuse the concepts class and object. However, the results of studies reported in the literature are not consistent. Holland et al. (1997), in contrast with Carter and Fowler (1998), state that some students confuse the two concepts and cannot differentiate between classes and their instances. The problem is more intense when the instructor uses examples that use just one instance of each class. Study review. The results of the teachings based on objectKarel and BlueJ were not the same. Specifically, the misconception recorded by Holland et al. (1997) was not confirmed for the objectKarel group, since 95% of the students differentiated between classes and their instances and gave a correct explanation for their answer. On the other hand, 47% of the BlueJ group seems to face difficulties, since 18% did not answer at all and 29% of them gave a wrong or insufficient explanation. Question 2: Is it possible for the way that an object responds to a message (or in other words the way that an object executes a method) to alter depending on the state of the object? Justify your answer. Literature review. Holland et al. (1997) state that “students may fail to realise that the behaviour of some objects may alter substantially depending on their state” (p.132), if the examples that are used “overemphasise the data aspects of objects at the expense of the behavioural aspect”. Of course, our hypothesis was that the misconception that “objects are simple records” would not be recorded in our studies, since: •
both language and the environment of objectKarel emphasise the behavioural aspect of objects
•
the projects used in the BlueJ study, that is the projects described in the book “Objects First with Java: A practical introduction using BlueJ”, are well-designed and do not treat objects as database records.
Study review. As expected, the misconception that ‘objects are simple records’ and respond to a message in the same way at all times independently of their state (Holland et al., 1997) was not recorded in the answers of the objectKarel group. However, our hypothesis was not confirmed for the BlueJ group too. Specifically, the misconception mentioned earlier was recorded in the answers of many students. Twenty four percent of the students gave a full answer and 12% answered correctly but gave wrong explanation.
A proposal for teaching Object-Oriented Programming
49
Question 3: Can we send more messages to an object through a single message? Give an example. Literature review. The third and fourth question were motivated by the misconception that “work in methods is exclusively done by assignment (and not by message passing)” (p.132), recorded by Holland et al. (1997). Of course, this misconception suggests that students comprehend that the state of an object can change when it executes a method, but they have the impression that this is accomplished with assignment rather than method passing. However, besides checking, if this misconception is confirmed we also wanted to test to what degree students comprehend that the execution of a method may alter the state of an object (Question 4). Study review. The misconception that “work in methods is exclusively done by assignment (and not by message passing)” (Holland et al., 1997) was not confirmed for the objectKarel group. This result was expected, since with the specific programming language and the visual step-by-step execution of programs, it would be very difficult for students not to comprehend that work in messages/methods is accomplished with method passing. As for the BlueJ group, 47% of the students gave a correct answer, but from them 26% gave a full answer (including a correct example). However, we cannot claim that half the students of the BlueJ group have acquired the specific misconception, since 41% did not answer at all. Question 4: Can a method change the state of the object that executes it? Give an example. Literature review. See the subsection ‘Literature review’ of Question 3. Study review. Although this question seems simple enough and one would expect that all, or at least nearly all, the students would answer it correctly; this was not the case for the BlueJ group. The fact that the majority of students (59%) in the BlueJ group did not answer this question at all – even without justification – clearly shows that students face difficulties. On the other hand, the objectKarel group seems to have fully comprehended the relation between an object’s state and method execution. Question 5: In the context of the 5th question students were asked to study a piece of code containing the interface of three classes that made use of inheritance and a test class where three objects were constructed (one of each class), and then define: (1) the names of the objects; (2) the initial values of the properties/fields of each object; and (3) the names of the messages that each robot can respond to (or in other words the methods that it can execute). Literature review. Our aim with this question was to test whether students confuse the concepts ‘class’ and ‘object’ as stated by Holland et al. (1997) or not (Carter and Fowler, 1998). This was explicitly asked to students in the 1st question, but in the 5th question students had to extract the corresponding information from a piece of code. Furthermore, we wanted to investigate whether students can extract correct information from a piece of code that implements multilevel inheritance, since we were not able to track down any relevant results in the literature.
50
S. Xinogalos
Study review. The results of the answers that were given by the two groups of students were different, as was the case for the previous questions too. For the objectKarel group, the students’ answers on this question combined with the answers on the first question make clear that: •
all the students comprehended the concept of class, object and object’s properties
•
half the students (53%) seem to have comprehended the concept of multilevel inheritance.
For the BlueJ group, it became clear that: •
Many students face difficulties with the concepts class, object and object’s properties, while several students seem to confuse the name of an object with the name of its class.
•
Students’ difficulties related to multilevel inheritance are clearly much more severe.
It is surprising that none of the students recognised that the source code presented to them – in fact just the interface of three classes – implements a 3-level inheritance. Question 6: In the context of the last question students were asked to study two different versions (called cases A and B) of two classes implementing a polymorphic method. The difference in the 2nd class of case B was that the polymorphic method was overridden, and the overriding method used duplicate code instead of making a super call to the overridden method. Students had to answer the following questions: (1) Is it possible for methods of different classes to have the same name? If yes, which is the difference in cases A and B? (2) In case Β could the method be implemented in a different way? If yes, write the new definition of the method. (3) Could we have one instead of two classes? If yes, write the new program. Literature review. The concepts of polymorphism and overriding, as known, cause many difficulties to students. Of course, this is not surprising if we take into account that students, as shown from the answers to the previous question too, face difficulties with multilevel inheritance. Fleury (2000), for example, has found that one-third of students believe that “the Java compiler can distinguish between same-named methods only if they have differences in their parameter lists” (p.198). In other words, one-third of the students believe that we cannot have methods with the same name in different classes. One of the aims of this question was to check if this misconception is confirmed in the teaching of OOP with objectKarel and BlueJ. Furthermore, we wanted to study whether the students can differentiate between polymorphism and overriding. Finally, we wanted to study if students understand the concept of class reuse, or they find duplicate code easier, as Fleury (2001) and Topor (2006) have stated. Study review. Fleury’s result that one-third of the students believe that we cannot have methods with the same name in different classes was not confirmed for the objectKarel group, but it was confirmed for the BlueJ group. It is not easy to give with certainty the percentage of students that has this conception, since 70% of the students of the BlueJ group did not answer the corresponding question at all. Ninety five percent of the students of the objectKarel group, and 18% of the BlueJ group recognised the difference between cases A and B, which lies in the super/parent class of the 2nd class.
A proposal for teaching Object-Oriented Programming
51
However, only 16% of the students of the objectKarel group (and no one of the BlueJ group) made a reference to polymorphism and overriding and explained their meaning. Of course, we could not expect more from the objectKarel group, since only a 2 h lesson was devoted to polymorphism and overriding. The fact that students face difficulties with the concepts of polymorphism and overriding was confirmed in our study. In the second part of the question, 37% of the students of the objectKarel group recognised the use of duplicate code in case B and used a super call to the overridden method. For the BlueJ group, this percentage was 3%.
5.2 Analysis of objectKarel questionnaire answers In this section, we present the answers and the conclusions drawn from the final questionnaire that was answered by the objectKarel group. Before the analysis of the results, we would like to mention that only ten students that had attended an OOP course – based on Java – prior to the lessons with objectKarel, answered the 4th and 5th question. Question 1: What differences – similarities did you locate in the problems that you solved in the context of the lessons based on objectKarel and those solved in other programming courses? Eighteen students answered this question. The most prominent similarity, between objectKarel and other programming languages, according to half of the students is the syntactic rules and mainly the selection and repetition structures. Another similarity that was detected by five students refers to the “main concepts of programming” and the “rationale of the problems”, to use their word-formation. The differences that were mentioned by students refer mainly to the advantages of the series of lessons based on objectKarel and the programming environment that helped them in solving the problems, and not to the problems themselves. Students mentioned as differences the “visual execution and result”, the “execution of an incomplete program”, the “step by step execution”, the “use of images and animation” and the “more pleasant environment” of objectKarel. Question 2: Do you believe that this series of lessons helped you in understanding programming concepts? The vast majority of students (83%) believe that the series of lessons based on objectKarel assisted them in understanding the concepts of programming, while the rest of them answered “I do not know”. Question 3: Do you believe that you would have faced fewer problems if you had been introduced to programming with objectKarel? If yes, which one of the problems that you faced in your introduction to programming do you think that you would not face? The replies in this question show that 79% of the students believe that they would have faced fewer problems if they had been introduced to programming with objectKarel, while 21% of them answer “I do not know”. As for the problems, several students incorporated in their answers the fact that they would not face problems with the syntactic rules of the programming language and they would comprehend better the main
52
S. Xinogalos
programming concepts and structures if they had been introduced to programming with objectKarel. The rest of the answers cannot be categorised because of the small number of students and the variety of their answers. However, we believe that it would be useful to record some of their answers: “easier detection of errors”, “it would be easier to interpret a problem from natural language to an algorithm”, “everything was easier”, “it would help me to comprehend easier the way of thinking that is demanded in order to solve programming problems”, “I would not be afraid of programming”. Question 4: Did the programming language and the environment of objectKarel help you clarify any concepts that you had not understood or that you had difficulty with? All the students stated that the programming language and the environment of objectKarel helped them understand some concepts that they had difficulty with or that they did not understand at all. Question 5: Do you believe that after this series of lessons you would face difficulties with the taught concepts in a conventional programming language such as C++ or Java? Seventy percent of the students believe that after the series of lessons based on objectKarel would not face problems with the concepts of OOP in a conventional programming language such as C++ or Java. What we would like to mention is that the 10 students who answered this question (and the previous one) had already been introduced to OOP with Java and knew its main characteristics and its difficulties.
6
Conclusions and proposals
Various teaching approaches have been proposed for making the teaching and learning of OOP concepts easier and more effective. In this paper, we tried to study the didactic effectiveness of two distinct teachings based on the well-known environment BlueJ and the microworld objectKarel. Although, the two teachings cannot be compared directly, and this was not our aim, the results of the common test taken by the two groups of students after the end of the two teachings shows clearly that the students taught with objectKarel were found to have a significantly better conceptual grasp of basic OOP concepts than the students taught with BlueJ. Furthermore, significant deviations were recorded in comparison with the results recorded in the literature. In conclusion, objectKarel seems to be a better choice when the goal of teaching is a deep comprehension of fundamental OOP concepts. However, objectKarel cannot support standalone the teaching of more advanced OOP concepts, or a conventional programming language, such as Java. BlueJ is an ideal environment for such teachings, and is used for this purpose in many Educational Institutes. Although this is the common case, our empirical study implies that the combined use of objectKarel and BlueJ could have even more positive results. We believe that the use of objectKarel for presenting the basic OOP concepts at the very first lessons of a course, followed by a conventional teaching based on BlueJ would provide the maximum support to students struggling with understanding the essence of OOP concepts and learning the language’s syntax.
A proposal for teaching Object-Oriented Programming
53
The question that remains to be answered is whether the knowledge acquired in the context of teaching with objectKarel will be transferred afterwards to the teaching with BlueJ. Although we do not have empirical data to answer this question, students’ answers to the questionnaire given to the objectKarel group give us some indications. The vast majority of students (83%), who had been unsuccessfully introduced to programming in the past, believe that the series of lessons based on objectKarel assisted them in understanding the concepts of programming, while half of them recognised similarities between the language of objectKarel and the conventional language(s) they had been previously taught with. Also, 79% of the students believe that they would have faced fewer problems if they had been introduced to programming with objectKarel. Ten students of the objectKarel group who had been previously been taught OOP with Java stated that the teaching with objectKarel helped them understand some concepts that they had difficulty with or that they did not understand at all, while 70% of them believe that they would not face problems with the concepts of OOP in a conventional programming language such as C++ or Java after the teaching with objectKarel. On the basis of our experiences from the two teachings, the long-term assessment of the course based on BlueJ (Xinogalos et al., 2007) and the results of the study, we designed a series of lessons (Table 2) with the aim of exploiting the advantages of both teachings. In the proposed series of lessons, objectKarel will be used in the first two lessons for introducing students to all the fundamental concepts of OOP – objects, classes, messages/methods, object construction, (multilevel) inheritance, polymorphism and overriding – and supporting them in comprehending their meaning. After this introduction to the fundamental concepts of OOP with objectKarel, BlueJ and the accompanying projects will be used for revisiting the fundamental OO concepts presented in objectKarel in a more formal way, using Java as the programming language. Each OOP concept will be examined repeatedly and in more depth, while new concepts will be presented. Table 2
Series of lessons based on objectKarel and BlueJ
Lesson Environment
Content
1
objectKarel
Objects, classes and inheritance
2
objectKarel
Multilevel inheritance, polymorphism and overriding
3
BlueJ
Objects and classes, parameters, class definitions
4
BlueJ
Object interaction: objects creating objects, multiple constructors
5
BlueJ
Static methods: the main method, executing without BlueJ
6, 7
BlueJ
Grouping objects in flexible size collections, fixed size collections
8
BlueJ
Using class libraries (the classes Random, HashMap, HashSet)
9
BlueJ
Designing classes, cohesion, code duplication, code reuse
10
BlueJ
Improving structure with inheritance
11
BlueJ
Polymorphism, overriding
12
BlueJ
Abstract classes and interfaces
54
S. Xinogalos
The proposed series of lessons is going to be applied, evaluated and refined (if needed) in the context of the compulsory course “Object-Oriented Design and Programming” at the Department of Technology Management at the University of Macedonia in Greece during the academic year 2008–2009.
References Barnes, D. and Kölling, M. (2004) Objects First with Java: A Practical Introduction using BlueJ, Prentice-Hall/Pearson Education, Harlow, England. Bergin, J., Stehlik, M., Roberts, J. and Pattis, R. (1997) Karel++ – A Gentle Introduction to the Art of Object-Oriented Programming, John Wiley & Sons, New York. Buck, D. and Stucki, D.J. (2000) ‘JKarelRobot: a case study in supporting levels of cognitive development in the computer science curriculum’, ACM SIGCSE Bulletin, Vol. 33, No. 1, pp.16–20. Carter, J. and Fowler, A. (1998) ‘Object oriented students?’, SIGCSE Bulletin, Vol. 28, No. 3, p.271. Cooper, S., Dann, W. and Pausch, R. (2000) ‘Alice: a 3-D tool for introductory programming concepts’, Journal of Computing in Small Colleges, Vol. 15, No. 5, pp.108–117. Fleury, A. (2000) ‘Programming in java: student-constructed rules’, ACM SIGCSE Bulletin, Vol. 32, No. 1, pp.197–201. Fleury, A. (2001) ‘Encapsulation and reuse as viewed by java students’, ACM SIGCSE Bulletin, Vol. 33, No. 1, pp.189–193. Holland, S., Griffiths, R. and Woodman, M. (1997) ‘Avoiding object misconceptions’, ACM SIGCSE Bulletin, Vol. 29, No. 1, pp.131–134. Hristova, M., Misra, A., Rutter, M. and Mercuri, R. (2003) ‘Identifying and correcting java programming errors for introductory computer science students’, ACM SIGCSE Bulletin, Vol. 35, No. 1, pp.153–156. Kölling, M., Quig, B., Patterson, A. and Rosenberg, J. (2003) ‘The BlueJ system and its pedagogy’, Journal of Computer Science Education, Vol. 13, No. 4, pp.249–268. Nevison, C. and Wells, B. (2003) ‘Teaching objects early and design patterns in java using case studies’, Proceedings of the 8th Annual Conference on Innovation and Technology in Computer Science Education, Thessaloniki, Greece, pp.94–98. objectKarel (2005) Available at: http://www.csis.pace.edu/~bergin/temp/findkarel.html, last accessed on October 2008. Parker, K.R., Ottaway, T.A. and Chao, J.T. (2006) ‘Criteria for the selection of a programming language for introductory courses’, Int. J. Knowledge and Learning, Vol. 2, Nos. 1–2, pp.119–139. Pattis, R.E., Roberts, J. and Stehlik, M. (1995) Karel the Robot: A Gentle Introduction to the Art of Programming, 2nd ed., John Wiley & Sons, New York. Proulx, V., Raab, R. and Rasala, R. (2002) ‘Objects from the beginning – with GUIs’, Proceedings of the 7th Annual Conference on Innovation and Technology in Computer Science Education, Aarhus, Denmark, pp.65–69. Sanders, D. and Dorn, B. (2003) ‘Jeroo: a tool for introducing object-oriented programming’, ACM SIGCSE Bulletin, Vol. 35, No. 1, pp.201–204. Topor, R. (2006) Common (Java) Programming Errors, http://www.cit.gu.edu.au/~rwt/p2.02.1/ errors.html (last access May 2006). Xinogalos, S. (2002) Educational Technology: A Didactic Microworld for an Introduction to OOP, PhD Thesis, University of Macedonia, Thessaloniki, Greece.
A proposal for teaching Object-Oriented Programming
55
Xinogalos, S. and Satratzemi, M. (2005) ‘Using hands-on activities for motivating students with OOP concepts before they are asked to implement them’, ACM SIGCSE Bulletin, Vol. 37, No. 3, p.380. Xinogalos, S., Satratzemi, M. and Dagdilelis, V. (2006) ‘An introduction to object-oriented programming with a didactic microworld: objectKarel’, Computers and Education, Vol. 47, No. 2, pp.148–171. Xinogalos, S., Satratzemi, M. and Dagdilelis, V. (2007) ‘Re-designing an OOP course based on BlueJ’, Proceedings of the 7th IEEE International Conference on Advanced Learning Technologies (IEEE ICALT 2007), 18–20 July, Niigata, Japan, pp.660–664.