Teaching Computer Programming to Non-computer Science Students
Weijun Chen, Xiu Li, Weidong Liu
(pp. 784-795)
The Asian Conference on Education
Official Conference Proceedings 2011
ISSN: 2186-5892
Proceedings URL: http://iafor.org/ace_proceedings.html
iafor
The International Academic Forum www.iafor.org
Title:
Teaching computer programming to non-computer
science students
Authors:
Weijun Chen
Xiu Li
Weidong Liu
Affiliations:
Department of Computer Science, Tsinghua University
Contact Information:
Department of Computer Science, Tsinghua University,
Beijing, 100084, P. R. China
[email protected]
Topic of the submission:
Teaching computer programming to non-computer science students
Weijun Chen, Xiu Li, Weidong LiuDepartment of Computer Science, Tsinghua University, Beijing 100084, P. R. China
Abstract. The paper presents the teaching of a computer programming course
for non-computer science students. The biggest challenge is that the students are from different majors and they have few (if not zero) prior programming experience before taking this course. To make the course successful and to im-prove students’ programming ability, we proposed three teaching techniques. The first technique is teaching with examples. If a student is not well trained, he doesn’t know how to analyze the description of a programming problem. To solve this problem, we provide more than 40 carefully selected examples in our lectures, through which the students will learn the basic analysis techniques. The second technique is teaching with patterns. Another challenge for a student is that when he is given a new programming problem, he feels it difficult to de-sign an algorithm. To solve this problem, we propose the concept of “pro-gramming pattern”. A pro“pro-gramming pattern is a piece of commonly used algo-rithm. For a new problem, we can try to divide it into different components, and each component can be solved with a pattern that we learned before. The third technique is teaching with exercises. Even if a student has thought of a good al-gorithm, he may still fail to write the correct source code. To solve this problem, we developed a powerful online training system which can edit, compile and score the students’ programs automatically. The examination results and the feedbacks of the students indicate that they achieved major improvements after the course.
1 Introduction
Introduction to Computer Programming is an introductory programming course for non-computer science undergraduate students at Tsinghua University, China. It is an optional course for anyone interested in studying computer programming. The course focuses on common computational problem solving techniques and no prior programming experience is assumed, although students should know the basics of using a computer (e.g., using a web browser and word processing software). The course is given in one semester of sixteen weeks, and in each week, there is one three-hour lecture and one three-hour lab session. Gen-erally there are more than 120 students in the class, they are from different majors such as materials science and engineering, chemical engineering, hydraulic engineering, mechanical engineering, automotive engineering and building science & technology. The textbook is Computer Language and Programming, which was written specifically for this course by the first author of this paper.
During the study of the course, the students will master the basic procedural programming techniques using the C language. They will learn to write and debug small C programs (50 - 100 lines) using a variety of input sources (console, file) and a variety of output destinations
(console, file, graphical). Students will also learn the design principles that are relevant to this style of programming. Topics covered in the course include:
Introduction: basic concepts of computer structure and program execution
Data types and expressions: variables, constants, data types, expressions and operators Simple control structures: sequencing, input and output, the if statement, the switch
statement
Iteration: the for loop, the while loop, the break and continue statements Arrays: one-dimensional arrays, two-dimensional arrays, character strings
Writing solid code: coding conventions (naming, comments, error handling, style and layout), program debugging, test cases development
Functional abstraction: definition and declaration of a function, parameter passing, re-turn values, scope of variables, stack frames
Pointers: pointer variables, & and * operators, pointers as parameters, pointer and array, dynamic arrays, pointer arrays, pointer to pointer
Basic data structures: structs, struct arrays, -> operator, structs as parameters, linear list Introduction to algorithms: searching, sorting, recursive algorithms based on divide and
conquer, recursive algorithms based on backtracking
The authors of the paper have taught the course for several years and find that it is not an easy job. Firstly, the students are from different majors and they have few (if not zero) prior programming experience before taking the course. Furthermore, the course is an optional one for them and they may not spend as much time on it as their major courses. In each semester, we will make a simple investigation at the beginning of the course to know the students' backgrounds. All the students are divided into four groups. The first group has significant programming experiences, they attended programming competitions in high schools. The second group knows how to write simple programs using C or other languages. The third group knows nothing about programming, but knows the basics of using a computer. The last group never used a computer before. A typical investigation result is shown in Figure 1.
From the investigation findings we can draw a conclusion that most students have few prior programming experiences before taking this course.
Secondly, students don’t know how to learn a programming course. After several years of observation, we find that many students (especially Chinese students) are good at studying the textbook or learning the syntax of the C language. But they are not good at solving pro-gramming problems and writing solid codes. A common situation is that a student is quite familiar with the details of the syntax such as the different usage methods of ++ operator and the order of evaluation of operators. However, when he is given a practical programming problem, he will have no idea how to solve it. In fact, many students find programming to be difficult and disheartening. They may be stuck on a simple problem for a couple of hours or even several days. Furthermore, in China, most university-level programming courses are taught using the traditional approaches including a blend of lectures, reading and practical sessions. The emphasis is put on the study of a programming language itself and the test is in the form of short questions or multiple choices. Moreover, even the exams of the National Computer Rank Examination (NCRE) generally take the form of multiple choice questions and fill-in-the-blank problems. The environments for these types of approaches will only produce students who are good at studying language syntax, but not good at algorithm de-sign and code writing.
This paper presents a novel method of teaching computer programming course. The whole process of solving a programming problem is divided into three different stages. At each stage, a different teaching technique is employed.
The rest of the paper is organized as follows. In Section 2, we present the related works on the teaching of computer programming courses. Then we give a detailed description of our method in Section 3. In Section 4, the evaluation results are shown and discussed. Finally we conclude our work in Section 5.
2 Related Work
Previous research has shown that the skills required for computer programming are problem solving and analytical skills (Riley, 1981; Henderson, 1986; Maheshwari, 1997; Linn & Clancy, 1992). However, according to Riley (1981), many students, especially the first-year college students, have “woefully inadequate” problem-solving skills. Henderson (1986) notes that problem solving and analytical thinking skills are students’ major weaknesses in a computer science course and that the emphasis of the course should be put on these skills. Maheshwari (1997) notes that programming is a study in clear thinking and problem-solving, and it gives students wonderful practice at building representations and working in methodo-logical manner. He also argues that the top-down approach is important in solving program-ming problems, in which large problems are separated into manageable components that are solved individually and then assembled into the correct solution to the problem. Ismail (2010) interviews with five computer science lecturers from the faculty of computer science in a Malaysian university and these experts believe that most students take the skills in problem solving for granted and fail to identify their programming weaknesses. However, they dis-agree on the reasons behind the lack of these skills in this area.
In addition to problem solving and analytical skills, writing solid code is also important in computer programming. Bonar & Soloway (1989) report that many programming bugs can be explained as novices inappropriately using their knowledge of step-by-step procedural specifications in natural language. Programming bugs are viewed as patches generated in response to an impasse reached by the novice while developing a program; such patching strategies are called bug generators. Several bug generators are used to describe how natural language pre-programming knowledge is used by novices to create patches. Rist (1996) ar-gues that the main source of difficulty does not seem to be only on the syntax and concepts of the programming language. A student can understand a concept well, but still fails to use it appropriately.
Most of the introductory text books on computer programming emphasize on the study of a programming language. The C Programming Language (sometimes referred to as K&R) is a well-known programming book written by Kernighan & Ritchie (1988), the latter of whom originally designed and implemented the C language. Because the book was co-authored by the original language designer, and because the first edition of the book served for many years as the de facto standard for the language, the book is regarded by many to be the au-thoritative reference on C. However, in my opinion, the book is not suitable for a textbook because it doesn’t teach readers how to solve problems in C. A student may still sit around and don’t know what to do when he is given a practical programming problem, even after he has learned all the materials in the book.
There are also misunderstandings about the teaching methods of a computer programming course. Gal-Ezer (1996) notes that in most academic institutions, the first introductory course has not dramatically changed over the years, and it almost always involves the study of a programming language. Even if the teacher has introduction to algorithmics in mind, the emphasis in practice is on the technicalities of a programming language, coding and running programs on a computer. McGill and Volet (1997) found that most of the introductory courses in computer programming tend to overemphasize students' acquisition of the syntax of a particular programming language at the expense of their development of problem-solving strategies and their understanding of computer-programming principles. Furthermore, most programming courses are taught using the traditional approaches including a blend of lectures, reading and practical sessions (Gray, Boyle & Smith, 1998). In fact, when learning a programming course, the most important thing is not listening to lectures or reading text-book, but doing enough programming exercises. Practice makes perfect.
Many software systems have been proposed to train students' programming skills. For such a system, one of the core facilities is automatic assessment of programming assignments, which means that students can receive the feedbacks immediately after they have submitted their assignments. Automated assessment systems seem to have existed for as long as educa-tors have asked students to build their own software (Douce, 2005). The earliest example of automated testing of programming assignments may be found in Hollingsworth (1960). A grader program was run against a student program and two different results were returned, either “wrong answer” or “program complete”. A second-generation system can loosely be labeled as “tool based”. Assessment systems are developed using pre-existing tool sets and utilities supplied with the operating system or programming environment. Testing engines and systems are often used and activated in the form of command-line or GUI programming
tools. An example of a second-generation assessment tool can be seen in the work of Isaac-son and Scott (1989). The third generation assessment systems make use of developments in web technology and adopt increasingly sophisticated testing approaches. For example, Daly and his colleagues have developed a Java-oriented assessment system called RoboProf, de-ployed in an honors degree program at Dublin City University (Daly 1999; Daly and Wal-dron 2004). The system presents programming problems within a web browser and the stu-dent is asked to type a program into a text box. When complete, the assignments are submit-ted, compiled, and results returned.
3. The Method 3.1 Teaching Method
After teaching the Introduction to Computer Programming course for several years, we pro-pose a method that is different from traditional ones. Theobjective of the course is twofold. Firstly, it will teach students the basic procedural programming techniques using the C lan-guage. Secondly and the most importantly, it will improve students’ ability of computational problem solving.
The basic idea of our method is illustrated as Figure 2.
Figure 2. Programming model
As shown in Figure 2, computer programming can be regarded as the transformation from a practical problem specification to a piece of source code. The whole process can be divided into three steps, i.e. problem analysis, algorithm design and coding. For each step, we will propose a different teaching technique. Specifically, we provide plenty of programming ex-amples to show the students how to analyze a problem specification, and propose the con-cept of “programming pattern” to help students design appropriate algorithms. Lastly, an
online training software system is provided for the students to practice programming at any-time they like.
3.2 Teaching with Examples
Problem analysis is the first step in computer programming. Usually the description of a problem is a paragraph of sentences. If a student is not well trained, he doesn’t know how to analyze the problem, and how to find important information in the sentences. Actually, un-like the C programming language that has numerous reference books to introduce the lan-guage syntax in details, there are a few materials to help students develop their analytical skills. Even in a programming course, the lecture may take these skills for granted and the students have to learn all by themselves. This is one of the main reasons that students still don’t know what to do when given a practical programming problem even after they have mastered the language syntax and finished a term of course.
To solve this problem, we provide more than 40 programming examples in our lectures. Through these examples, the students will learn the basic analysis techniques. Actually, only one third of the lectures are about the C language itself, including the syntax and concepts of the language, all the others are different types of programming examples.
Figure 3 is a programming example in our lectures, the Hanoi problem. The description of the problem is summarized as follows: there are three poles in an ancient Indian temple. These poles are named as A, B and C. There are totally 64 golden discs placed at the pole A, each disc is on the top of another. Disc #1 is smaller than disc #2, and disc #2 is smaller than disc #3, etc. We need to move all the discs from pole A to pole C with the restrictions that only one disc can be moved each time and at any time no bigger discs can be placed on the top of smaller ones.
Figure 3. The Hanoi problem
During the course lectures, we will illustrate students how this problem is solved step by step. Firstly, we will consider the simplest case, i.e., there is only one disc at the pole A. In such case, students will find out the answer easily. Secondly, we will consider another simple case, i.e., there are two discs at the pole A and disc #1 is on the top of disc #2. Thirdly, we will consider a relatively difficult case, i.e., how to move three discs from A to C. In such case, we need to put the problem in a quite different view, we need to think of it recursively. Lastly, we will generalize the problem to arbitrary number of discs.
3.3 Teaching with Patterns
In our observations, the biggest challenge for a student is that when he is given a new prob-lem, he has no feelings and don’t know what to do. He feels it is difficult to design an algo-rithm. Actually, in many programming courses, students are not taught and exposed to proper algorithm solution.
To solve this problem, we employ the concept of “programming pattern”. A programming pattern is a piece of commonly used algorithm. Here are some examples:
Calculate the sum of a variety of numbers
Find the maximum/minimum value among a set of numbers
Compute the frequency of each word that occurs in a paragraph of text
When a student is given a new problem, he can try to decompose it into several smaller prob-lems, and each problem can be solved using a programming pattern that he is previously familiar with. After that, he can just combine these patterns together and the original prob-lem is solved.
Here is a simple example of how this concept is used in our teaching. Suppose the students are given a new programming problem:
Get a series of integers from the user and count the numbers of negative and positive values. The total number of these integers is unknown and we will stop when a "sentinel value" (i.e. 0) is received.
When the students firstly see this problem, they feel it is difficult and have no idea about what to do. However, after the analysis, this problem can be decomposed into two smaller problems. The first one is how to get a series of integers from user until a special value is encountered. The second one is how to process these integers and calculate the numbers of positives and negatives. And in the previous sections, we have already met a problem named Robust Input:
Read in a parameter for a function and ensure that the value is in a valid range.
When solving that problem, we have already extracted a programming pattern “read in a series of values repeatedly until a valid one is encountered”. It is obviously that this pro-gramming pattern can be used to solve the first problem here.
In the previous sections, we have also met another problem named Gauss’s Problem:
In such problem, we have proposed another programming pattern “calculate the sum of a variety of numbers”. It is obviously that this programming pattern can be used to solve the second problem here.
Now we have decomposed the original problem into two smaller ones, and each smaller problem can be solved using a programming pattern that we learned previously, therefore the only thing we need to do is to combine them together.
3.4 Practice Makes Perfect
The last step in computer programming is coding, i.e., translating an algorithm into the cor-responding source code. This is not an easy and natural thing for an inexperienced student. Actually, even if a student has thought of a good algorithm, he may still fail to write the cor-rect source code. You can always see a student, sitting in front of a computer for a long time, just to locate a small bug in his code.
To solve this problem, and to help student learn by themselves, we developed an online training system - Kaleidia.
Figure 4. The Kaleidia system
Kaleidia is a powerful web-based self-learning system. The users are categorized into three different types: teachers, students and administrators. All the lecture notes are posted on the website by the professor, and students can download them to their local computers freely or view the lectures online. They can also post articles about the course and seek for help on the website. A live chat tool is provided which make it possible for online students to communi-cate with each other quickly and share their ideas freely.
Another important feature of Kaleidia is programming practices. The professor will post the exercise assignments on the website every week, the students can edit the source code, com-pile it and debug the program online. When the students press the “submit” button, Kaleidia system will score their programs automatically, so the students will know the scores imme-diately. This is important for a programming practice because the students don’t have to wait for a couple of days to know the result after they submit their source code, which means that they can practice programming at any time their like.
4. The Results
The above method has been applied in the Introduction to Computer Programming course for several years and major progress was observed. At each semester’s end, there will be a programming exam when the course is finished. The exam generally consists of six pro-gramming problems, the students are supposed to finish all of them in three hours. The maximum score is 100 points and the minimum is 0. Figure 5 is the examination result of a recent semester.
Figure 5. The examination result
The examination result shows that the students achieved major improvements after taking this course, about one third of the students achieved high scores and only four students failed. At Tsinghua university, every time when a course is about to finish, all the students will evaluate the course and the teacher online. There are different items such as Devotion and Passion, Clear, Well-organized course structure, etc. For each item, if the score ranks top 15% among all the courses, there will be a smiling face. But if the score rank the last 15%, there will be a crying face. In a recent semester, we got 8 smiling faces and no crying faces. The following are some of the students’ feedbacks:
The classroom atmosphere is involving and enjoyable, the teacher is humorous, the lan-guage is so precise that make the abstract principles much easier to understand.
The teaching style is unique and attractive. Just one word: terrific!
5 Conclusion
The paper presents a novel method of teaching a computer programming course to non-computer science students. The whole process of solving a programming problem is divided into three different stages, i.e., problem analysis, algorithm design and coding. At each stage, a different teaching technique is employed. The evaluation results show that the students achieved major improvements after taking the course, and most of the feedbacks of the stu-dents are pretty positive.
Ongoing and future work includes the further improvements of these teaching techniques. More sophisticated methods will be used to accurately investigate the real status of the stu-dents after taking the course. We want to know exactly which type of skill is improved and which one is not. We will also like to improve the online training system and provide the student with a more powerful and convenient training platform.
References
1.Bonar, J. & Soloway, E. 1989, Pre-programming knowledge: A major source of miscon-ceptions in novice programmers. In Soloway & Spohrer (1989), Studying the Novice Pro-grammer (pp. 325-354), Mahwah, NJ: Erlbaum.
2.Daly, C. 1999, RoboProf and an introductory computer programming course. In Proceed-ings of the 4th Annual SIGCSE/SIGCUE ITiCSE Conference on Innovation and Technol-ogy in Computer Science Education. 155-158.
3.Daly, C. and Waldron, J. 2004, Assessing the assessment of programming ability. In Pro-ceedings of the 35th SIGCSE Technical Symposium on Computer Science Education. 210-213.
4.Douce, C. 2005, Automatic Test-Based Assessment of Programming: A Review. ACM Journal of Educational Resources in Computing. 5(3), 1531-4278.
5.Gal-Ezer, J. 1996, A pre-programming introduction to algorithmics. Journal of Mathemat-ics and Computer Education. 30(1), 61-69.
6.Gray J, Boyle T. and Smith C. 1998, A constructivist learning environment implemented in Java. In proceedings of ItiCSE ‘98 - Integrating Technology into Computer Science Education, pp. 94-97. ACM Press
7.Henderson, P. B. 1986, Anatomy of an introductory computer science course. Proceedings of the 17th SIGCSE ’86: Technical symposium on Computer Science Education, pp. 257-263, New York: ACM Press.
8.Hollingsworth, J. 1960, Automatic graders for programming classes. Commun. ACM 3, 10, 528-529.
9.Isaacson, P. C. and Scott, T. A. 1989, Automating the execution of student programs. SIGCSE Bull. 21, 2, 15-22.
10.Kernighan B. W. & Ritchie D. M. 1988, The C programming language. Prentice Hall. 11.Linn M. C. & Clancy M. J. 1992, The case for case studies of programming problems.
Communications of the ACM, 35(3), 121-132.
12.Maheshwari, P. 1997, Teaching programming paradigms and languages for qualitative learning. Proceedings from ACM International Conference Proceeding Series ’97: Pro-ceedings of the second Australasian Conference on Computer Science Education, pp. 32-39, New York: ACM Press.
13.McGill, T. J. & Volet, S.E. 1997, A conceptual framework for analyzing students’
14.Ismail M. N., Ngah N. Z., Umar I. N. 2010, Instructional strategy in the teaching of
com-puter programming: a need assessment analyses. The Turkish Online Journal of Educa-tional Technology, April 2010, volume 9 Issue 2, 125-131.
15.Riley, D. 1981, Proceedings from Technical Symposium on Computer Science
Educa-tion ’81: Proceedings of the twelfth SIGCSE Technical Symposium on Computer Science Education, pp. 244-251, New York: ACM Press.
16.Rist, R. 1996, Teaching Eiffel as a first language. Journal of Object-Oriented Program-ming, 9, 30-41.