Experiences with teaching object-oriented concepts to introductory programming students using C++

Experiences with teaching object-oriented concepts to introductory programming students using C++ Judy Sheard and Dianne Hagan Department of Software ...
Author: Judith Russell
0 downloads 3 Views 44KB Size
Experiences with teaching object-oriented concepts to introductory programming students using C++ Judy Sheard and Dianne Hagan Department of Software Development Monash University Australia

{judy.sheard, dianne.hagan}@fcit.monash.edu.au Abstract With the growth in popularity of the object-oriented paradigm, the Department of Software Development at Monash University decided, two years ago, to teach object-oriented programming to the introductory programming students. The first year programming subjects were completely restructured and rewritten. It was decided to introduce the objectoriented paradigm after the students have had one semester of procedural programming experience in C++. Teaching object oriented principles in C++ has presented many challenges. The students find the complicated language syntax difficult. They also show a reluctance to move from the procedural to the object-oriented paradigm. However, with support and advice from education experts we have successfully addressed these problems. Different teaching approaches and techniques have been used. Small discussion classes were introduced to provide a forum for the consolidation of ideas presented in lectures, away from the distraction of computers. Extra support was given to the students in the form of a special World Wide Web page and a help desk. A concurrent research project has enabled close monitoring of the effectiveness of our teaching programme. In spite of the difficulties we have faced,

the student results for 1995 and 1996 show an improvement in student performance over previous years.

1. Introduction The decision by the Department of Software Development of Monash University to teach objectoriented programming in the introductory programming subjects in the Bachelor of Computing course has meant a complete redesign of the first half of the three year degree course. The new first year programming subjects with an object-oriented focus were introduced in 1995 and with significant modifications were taught again in 1996. A research project with the Education faculty which investigated the teaching of introductory programming during 1995 and 1996 has enabled a close monitoring of these subjects. This project has provided valuable insights into the teaching and learning within these subjects and a wealth of information has been gained about the effectiveness of the introduction of the object-oriented style of programming into the course. Although teaching object-oriented programming to first year students has been successful, the transition from the procedural programming style has been difficult and has required extra and different support from teaching staff and reorganisation of the teaching programme.

2. Background - old course to new course Prior to 1994, students were required to study programming subjects in each of the three years of the Bachelor of Computing (Information Systems)

degree. For the first two years, four compulsory programming subjects were taught and, in the final year, students were able to choose from a small number of optional subjects. Students studied Scheme for one semester, COBOL for two semesters and then C for the final semester in second year. In third year, students had a choice of programming subjects. One of these was a subject called Objectoriented Programming Systems in which the students learnt Eiffel. This subject was introduced in 1992 and quickly gained in popularity. It was the first subject to offer object-oriented programming in the undergraduate degree course. In 1994, after an extensive review, the current Bachelor of Computing course was introduced. In this new structure, students are given much more flexibility in the choice of subjects. Students now study three consecutive compulsory (core) programming subjects in the first three semesters of the course. When these have been completed, the students decide upon one or two particular areas of computing that they wish to concentrate on, and are able to choose from a large variety of subjects. For the last half of the degree there are no compulsory programming subjects. Currently, we are finding that only about one quarter of the students are choosing a programming focus. Many students find programming difficult and prefer instead to study other aspects of computing. The three core programming subjects in the first three semesters are the only programming subjects that many students now study. This compares to six programming subjects in the old degree, four of which were compulsory. The content of these three core units must therefore give the students all the basic programming experience we consider necessary for anyone with our computing degree.. These subjects needed careful consideration and planning to include all the material we wish to teach the students.

3. Choice of language in the new course The language or languages to teach the students in the three core programming units caused much debate within the Department. With only three core subjects instead of four there was not much flexibility.

In the old course, the students learnt Scheme in the first semester in first year. This was taught successfully as an introductory programming language and had the advantage of exposing students 1 to both the procedural and functional paradigms. After using Scheme, students found it easier to learn other languages such as C. In the second semester of first year students learnt COBOL. The Bachelor of Computing at the Caulfield campus has always had a very strong commercial relevance and our graduates are sought after by industry because of this. Therefore it was felt that the students should be taught a language that was in demand in industry. This was the case with COBOL, but not with Scheme. In second year, first semester, students continued with COBOL, using this language for larger program development. C was then taught in second semester. This gave the students experience with another language in demand by industry. One disadvantage of the old course was the change of languages in the middle of first year. By the end of first semester, students were just beginning to feel comfortable with programming in Scheme, only to have to start all over again with a new, very different language (COBOL) in second semester. The language decided upon for the first two core subjects in the new course was C. Although it was not considered ideal as an introductory programming language, it had some advantages. It was in high demand in industry. Surveys showed that the demand for C and COBOL at that time was about equal but the demand for C was increasing whereas the demand for COBOL was in a slow decline. Students learnt the same language for the whole of first year. They were much more enthusiastic about the prospect of learning C than COBOL which they saw as outdated and Scheme which they saw as irrelevant. C was also chosen for the third core subject which was a software engineering subject requiring students to work in teams writing large programs. After learning C for one year it was felt that the students would be confident and competent in the language 1

The term functional is used here to refer to a style of programming that makes use of function calls which return values

and able to concentrate on the software engineering issues rather than program syntax. These subjects were designed and used for one year before another change took place.

4. Introduction of object-oriented programming into first year During the 1990s, the Department of Software Development has developed a strong object-oriented focus, reflecting the increase in acceptance and use of object oriented programming in industry. The Department has organised TOOLS Pacific in Melbourne each year since 1994, and several members of the Department are involved in objectoriented interest groups such as ACS OOSIG (Australian Computer Society, Object-oriented Special Interest Group). During 1994, which was the first year of the new Bachelor of Computing course, the Department felt that it was important to expose all students to the object-oriented paradigm and therefore this should be included somewhere in the curriculum of the three compulsory programming subjects. Many students were now not choosing any programming subjects after the first three core subjects. It was decided to introduce object-oriented programming into the core subjects beginning in 1995 for reasons similar to those given in [Kolling 95]. The decision to teach object-oriented programming in 1995 meant changing the programming language taught in the three core subjects. C was no longer appropriate. A language that supported the objectoriented paradigm was needed. Languages such as Smalltalk, Eiffel, Java and C++ were considered. The language needed to be suitable to teach as an introductory language and also be used widely in industry. We also had to consider hardware requirements and the availability of suitable textbooks. After much consideration, C++ was chosen as the language which best fitted these requirements. Although it had shortcomings as a language to teach to beginning programming students [Koenig 96, Kolling 95], it was the most widely used object-oriented language in industry. It also supported the procedural programming paradigm which we felt was essential for the students to

encounter as we wanted them to have a broad view of the programming world [Budd 95]. There was a wide range of suitable textbooks and the C++ compiler we decided upon was able to run on the available hardware. There was very little C++ expertise within the Department. However, at this stage C had been taught for a year as a part of the new course and the transition from C to C++ for the staff was not expected to present any difficulties. In reality, though, moving from procedural programming in C to object-oriented programming in C++ was more difficult than we had anticipated [Ross 96]. Another deciding factor in the decision to use C++ was that either C or C++ was also used as an introductory programming language by other departments within the Faculty. There was strong pressure from the Faculty for uniformity to allow students easy transfer between courses. The problems of C as an introductory language had become very apparent during 1994. Students found the syntax difficult. The large number of operators, operator precedence, pointers, de-referencing, dynamic memory allocation and I/O formatting were just some of the problem areas. It was expected that some of the harder aspects of C such as pointers and I/O formatting would be easier in C++. However, having decided to use C++ as the vehicle to introduce object-oriented concepts, most of these difficulties were still with us, as well as the extra task of introducing another paradigm to the students. Initially, C++ was also chosen as the language for the first semester subject in second year; however, this subject now uses Eiffel.

5. Designing an object-oriented subject for introductory programming students The first year programming subjects are taught as an introduction to programming. The students are not expected to have any prior computing knowledge. Initially we considered teaching object-oriented programming from the beginning of first semester. This was to be a top-down approach initially looking

at how object-oriented design models the real world and then gradually looking at more and more complexity of design and implementation. This would have the advantage of facilitating the linking of programming abstractions to real life situations and enabling students to see a relevance to what they are learning. Students often find learning programming tedious in the beginning because there is so much detail to learn before they are able to do anything they find interesting. First impressions are often long lasting so we were anxious to try this new approach. However, after much consideration it was decided that this was not practical. We were committed to using C++ which we felt was not suited to using this teaching approach. Using C++, the object-oriented concepts we were trying to convey would quickly become buried in the complexity of the language syntax and end up confusing and discouraging the students. It would be very difficult for the students to understand the concept of classes and member functions without first having an understanding of types and functions. There were also very few textbooks available which began with the objectoriented paradigm. It was decided therefore to use the more traditional bottom-up approach and to introduce the object-oriented concepts to the students after they had had at least one semester of procedural programming [Adans 96, Ross 96].

6. Teaching object-oriented programming to first year students - 1995 Object-oriented programming was first taught to the first year programming students in 1995. In first semester, the students were taught program design using structure charts, testing strategies, and the basic concepts of sequence, selection and iteration and their implementation in C++. They learnt about functions, streams, standard and file I/O and the data structures of arrays and structs. By the end of semester, the students had built up confidence and skill in the basics of C++ through many small programming exercises and larger programming assignments. The aim was to establish a good grounding in the procedural programming style.

In second semester, object-oriented programming was introduced. This was done gradually, starting with the history and theory of the object-oriented paradigm. The benefits of and reasons for learning another paradigm were explained, although the students really understand these only after they have had practical experience. The concepts of classes, objects, identity, encapsulation, attributes and behaviour were discussed and examples of their implementation in C++ were demonstrated. Operator overloading and polymorphism were also taught but inheritance and templates were left for a later subject. Object-oriented programming was presented to the students as a different programming style; however, wherever possible, links were made to the programming knowledge they already had to help them with the transition to the new paradigm. For example, the similarity of structs and class definitions was emphasised. The students completed an assignment in a number of stages during the semester. They initially wrote a small program in a non-object-oriented style. The specification of the assignment was then extended and the program rewritten as an object-oriented version. Writing the program first in a familiar style helped them obtain a very good understanding of the problem definition and required results before they tackled the object-oriented style. When they rewrote the program using classes they were able to concentrate on the object-oriented aspects of the syntax and design. The students were shown OMT diagrams as a design tool. However, object-oriented design was not covered in much detail in this semester because of lack of time. After using structure charts as a design tool in first semester with almost direct translation into C++ code, the students found the lack of a similar design tool in object-oriented programming disconcerting. If more time had been available, we would spend it on design. The problem with C++ is that the syntax is so complicated that the students have difficulty seeing the “big picture” [Macdonald 96].

7. Research project The introduction of object-oriented programming into the first year programming subjects has coincided with a research project investigating the teaching and learning of introductory programming within the Faculty. This project began in late 1994 after concerns were raised about the high failure rates and low retention rates of first year programming students. This project is a collaborative effort between the Education Faculty and two departments within the Faculty of Computing and Information Technology, one of which is Software Development. The investigation was thorough and extensive. Lectures and tutorials were observed by education experts, and students and teaching staff were interviewed in depth. The project has produced many interesting findings on the teaching of introductory programming. However, as the initial investigation was held in 1995, during the first year of the introduction of the object-oriented paradigm to the first year students, it also provided a unique opportunity to assess the effectiveness of this aspect of the curriculum. The investigation found much evidence of dissatisfaction with the programming subjects: low attendance and lack of concentration at lectures, lack of motivation, high drop-out rates, etc. The students found C++ a difficult language to learn. However, the dissatisfaction increased in second semester when many students who had apparently coped well with first semester started to feel lost. This seemed to happen for many students about the time when the object-oriented paradigm was introduced. As a result of the report, Software Development decided to overhaul completely the first year programming subjects. This was be done with a great deal of input and support from the two education experts on the project team. It was decided to continue teaching object-oriented programming in first year. Even though this was obviously a problem area for the students, the education experts in the research group were confident that much could be done to assist them.

It was decided that in 1996 the two first year programming subjects would be rewritten and different teaching strategies would be tried.

8. Education input into subject content The lecture material for the two first year subjects received a complete overhaul during 1996. A team consisting of two first year computing lecturers and two education staff members met for two hours each week. For each lecture, every topic was discussed in minute detail. Valuable educational advice and innovative ideas were given by the education experts. The education people came from a non-programming background but they were willing learners. They endeavoured to understand each new concept presented and succeeded without too much effort until second semester when the object-oriented paradigm was introduced. They found the shift to the new paradigm very difficult. In their opinion the students would not see the necessity and benefits of changing to this new style when they had already learnt and mastered one that worked for them. The problem was also one of scale. In first semester the students were given small tasks each week and one assignment which could be completed in small stages. The students spent the last half of the second semester working on an assignment without a clearly defined path to follow. The education experts warned us that the students would need a great deal of assistance and encouragement to cope with this change - more than we had foreseen and more than we had given them in the previous year.

9. Teaching object-oriented programming to first year students - 1996 In 1996 the two first year programming subjects used the same bottom-up approach as were used in 1995, introducing object-oriented concepts in second semester. However, other significant changes were made. On advice from the education experts the subjects’ content was reduced. They felt that the students

needed more time to assimilate the new ideas we were presenting and this was one way of achieving this. Polymorphism and operator overloading were removed from the syllabus, as these had proved too complicated for the students in 1995. Arrays and structs were moved from first to second semester. In second semester more lectures were devoted to helping the students understand the object-oriented paradigm. At one stage when it was apparent that the students were not coping well, two lectures were devoted to consolidation and revision of the objectoriented concepts already covered. During one lecture, we used a role play to demonstrate the interplay of classes to be used in the assignment. The education experts encouraged an iterative approach to learning to continually reinforce concepts introduced earlier in the semester or in the previous subject. The education experts encouraged us, where possible, to generate a “need to know” so the students could see a purpose to what they were learning. More effort was made to help the students see the benefits of the object-oriented paradigm. During one lecture C++ applications written in the object-oriented style were demonstrated. These were games with attractive graphical interfaces, such as “solitaire” and “minesweeper”, designed and written by our third year undergraduate students. At this demonstration it was explained that object-oriented programming and design make applications of this complexity easier to implement than other styles of programming. The main experience the students had with objectoriented programming in second semester was in writing the assignment. In 1995 the students wrote an assignment which involved just three classes. The C++ code for one of these classes was given to the students. The assignment had a very straightforward specification. In 1996 the assignment involved six classes in which the C++ code for three classes was given to the students. The students therefore had to deal with twice as many classes. However the resultant increase in complexity with all the interrelating classes was more than double that of the previous year.

The 1996 assignment was considered by the teaching staff to be more interesting and better demonstrated the advantages of using object-oriented programming than the 1995 assignment. As in 1995, the students first wrote the assignment in a non object-oriented style and then rewrote it in an object-oriented style. However students had more difficulties with this assignment than in the previous year because of its size and complexity. To cope with this assignment the students needed assistance. Various ways of helping the students were discussed by teaching staff when it became clear that far too many students were not coping. We considered giving the students class designs or test driver programs for each class. However we decided against this because it was too prescriptive. By this stage many of the students had started the assignment and some students were well advanced with it. To fit in with what was handed out they would have had to modify, perhaps extensively, what they had already done and this would have been very frustrating. It was decided instead to make available to the students an example of one class with a sample of an incomplete driver program. This proved helpful and gave encouragement to students who had no idea where to start. For an initial assignment it is probably advisable to have a simple concept with perhaps no more than three or four classes. The tendency is to set something we hope the students will find interesting and which then ends up to be too hard. For an assignment involving more than about four classes some help such as pre-written or explicitly designed classes, skeletons of some of the classes or test driver programs should be given to the students. After a semester of using functional decomposition they naturally think with this approach. To start with designing classes and then work towards a solution is very difficult for them. A difficulty with using C++ is that it is not a pure object-oriented language. Students had difficulty deciding what belonged in a class and what should be outside, i.e. where the object-oriented part started and finished.

10. Changes to subject presentation The first year programming subjects were traditionally taught with one two-hour lecture and one two-hour tutorial held in a computer laboratory . It was decided instead in 1996 to divide the lecture into two one-hour lectures and present these on separate days. The education people felt that it was unreasonable to expect the students to concentrate for a two hour span and there was evidence from observations of lectures to show that the students did not do this. In addition to the two hour tutorial in the computer lab, the students now attended a discussion class held in a normal classroom. This provided an opportunity for discussion of ideas, concepts and problems without the distraction of computers.

11. Discussion classes

a successful activity in aiding their understanding because of the mirroring of the object-oriented models to real life. In first semester, the particular concepts that students found difficult were largely anticipated because of the many years of experience teaching the procedural style of programming. However, this was not the case in second semester. We had not had the same depth of experience teaching object-oriented programming and relied heavily on student feedback to indicate problem areas. The discussion classes, because of the active student participation, helped give us insights into the students’ understanding of the concepts (or lack of same) at every stage in the semester. This enabled the teaching staff to make adjustments to the teaching program to assist the students at certain critical phases.

The discussion classes were used to consolidate concepts introduced in lectures. A big effort was made to encourage student participation. Special exercises were designed to engage students in discussion.

Surveys of students indicate that these classes were a significant factor in improved student performance [Macdonald 96].

The discussion classes were a success in first semester where they were used to help students with program design and strengthen their understanding of the basics of C++. They proved invaluable in second semester when object-oriented programming was introduced. The students needed a lot of support with the new paradigm and much of this was given in the discussion classes. A considerable time was spent discussing general object-oriented design, the design of individual classes and how different classes could be used together. When it became apparent that students were having difficulties with the assignment, the discussion classes were used to assist the students with this aspect of their work. Each class needed for the assignment was discussed in detail and different designs were suggested and evaluated. The assignment involved about five or six classes. Trying to see how these all fitted together was a complex problem for the students and in hindsight, the assignment was too difficult for the majority of the students. Role plays were used to help the students understand what each class should be able to do and also how they interacted with other classes. This was

A home page was set up on the World Wide Web for each first year programming subject. Students were able to access these to obtain information such as the subject handbook, staff timetables, lecture slides and class exercises. Students were also, via the home page, able to ask for help and give anonymous feedback to the staff. The anonymous feedback was not used much in first semester; however, in second semester, this was a useful source of student comment about various aspects of the subject. Many students were willing to comment anonymously but not to contribute to a newsgroup. The use of the WWW is described in detail in [Hagan 96].

12. World Wide Web support

13. Help desk A help desk was set up to give students support outside class time. All the first year tutors were rostered to staff this at certain times each week. This service was heavily used before assignment submission time. Students consult this service mainly with programming syntax or logic errors. However, when the students were working on the object-

oriented assignment, many of the questions asked of the help desk consultant concerned design strategy. For example. “What do I put in this class?” “How do I use these classes?” and even “Where do I start?”

14. Student results The students’ results in second semester since the introduction of object-oriented programming have shown a significant improvement. In 1994, before the introduction of object-oriented programming, 28% of the 255 students enrolled gained distinctions or high distinctions. In 1995, the first year that objectoriented programming was taught, this figure was 31% of the 252 students enrolled, a small increase. However, in 1996, with the input and advice from the education experts and the subject revision, this figure rose to 40% of the students enrolled. This increase occurred in spite of all the difficulties experienced with the assignment. In 1996 the examination was done better than in any previous year so even though the assignment was very challenging, the students seemed to have learnt a great deal from writing it.

15. Conclusion The decision to teach object-oriented programming in the first year of the Bachelor of Computing has necessitated extensive changes to the curriculum. C++ was chosen as the programming language to use because of its commercial relevance and despite its unsuitability as an introductory programming language. The students are introduced to the objectoriented paradigm after a semester of introductory programming in the procedural style. In 1996, in consultation with educational experts the teaching program was reorganised to assist with this difficult transition. A new discussion class was introduced, new teaching methods were tried and students were supported by a help desk and a World Wide Web home page dedicated to the subjects. A significant increase in student performance has been noted since these changes were implemented. Following the success of these initiatives, the Department of Software Development has continued to teach objectoriented programming to first year students in 1997.

References [Adams 96] Adams, J. (1996) Object-centered Design: A Five-phase Introduction to Objectoriented Programming in CS1-2, ACM SIGSCE Bulletin, Vol. 28, No. 1, March 1996, pp 78-82. [Budd 95] Budd, T. and Pandey, R. (1995) Never Mind the Paradigm, What About Multiparadigm Languages, ACM SIGSCE Bulletin, Vol. 27, No. 2, June 1995, pp 25-30. [Fienup 96] Fienup, M. (1996) Rethinking the CS-2 Course with an Object-oriented Focus, ACM SIGSCE Bulletin, Vol. 28, No. 3, September 1996, pp 23-25. [Hagan 96] Hagan, D.L. and Lowder, J. (1996) Use of the World Wide Web in Introductory Computer Programming, Proceedings of ASCILITE’96, Adelaide, 1996 [Koenig 96] Koenig, A. (1996) C++ as a First Language, Journal of Object-oriented Programming, June 1996. [Kolling 95] Kolling, M., Koch, B. and Rosenberg, J. (1995) Requirements for a First Year Objectoriented Programming Language, ACM SIGSCE Bulletin, 27, 1, March 1995, pp 173-177 [Macdonald 96] Macdonald, I. and Hagan, D.L. (1996) How education research became part of teaching first year programming, Paper presented in AARE conference, Singapore, 1996. [Reek 95] Reek, M. (1995) A Top-down Approach to Teaching Programming, ACM SIGSCE Bulletin, 27, 1, March 1995, pp 6-9. [Ross 96] Ross, J. (1996) Learning to Teach C++, ACM SIGSCE Bulletin, 28, 2, June 1996, pp 2530.