Objects-first vs. structures-first approaches to OO programming education: an empirical study.
Johnson, Richard A. ; Moses, Duane R.
INTRODUCTION
The teaching of introductory programming is a foundation in many
computer information systems (CIS) and computer science (CSC) curricula.
In recent years, virtually all introductory programming courses have
shifted from the procedural approach to the object-oriented (OO)
approach. Most beginning programming courses appear to be teaching Java
, C++, or one of the Visual Studio .NET languages (Visual Basic, C#, or
J#) as evidenced by the popularity of various computer programming
texts. All of these programming languages are OO, as contrasted with the
purely procedural languages of Fortran, Pascal, COBOL, and C.
The basis of any type of computer programming involves the three
programming 'structures': sequence (do A, do B, do C, ...),
selection (if...else decisions), and repetition (while or for loops).
The basics of OO programming involve creating classes that serve as
templates for instantiating objects in computer memory. Objects have
attributes (instance fields) and behaviors (methods) and usually
represent things in the real world (such as students, products, or
airline reservations). While learning the basics of structured
programming (sequence, selection, and repetition) is not always easy for
most beginning students of CIS and CSC, it is the general consensus that
learning OO programming concepts and techniques may be even more
challenging for most students (Sheetz, et al., 1997).
Therefore, one of the most relevant questions regarding how OO
programming courses should be taught is whether it is better to teach
structured programming concepts first, followed by OO programming
concepts, or vice versa. It appears that most authors claim it is better
to teach objects first ('early objects') in order to ingrain the student with OO concepts and techniques early and often, thus
ensuring greater success in later OO programming (Thramboulidis, 2003;
Ragonis & Ben-Ari, 2005). Although the 'objects first'
(OF) approach may sound more plausible than a 'structures
first' (SF) approach, there appears to be no empirical evidence to
support the claim. The purpose of this study is to perform a field
experiment to test the claim that OF is superior to SF.
RESEARCH METHOD
The research question driving this study is: What effect does
teaching an objects-first approach (vis-a-vis teaching a
structures-first approach) have on the performance of introductory
programming students in understanding OO concepts and writing OO
programs? The hypothesis being tested is that there is no difference in
the performance of introductory programming students when provided with
an objects-first or a structures-first approach to OO programming.
To test this hypothesis, the authors of this study each taught one
section of introductory OO programming (CIS 260) to a section of about
25 students during the Fall 2007 semester at Missouri State University (MSU). These instructors had already been scheduled to teach these
sections, so it was not possible for the same instructor to teach both
sections due to scheduling conflicts. To minimize the differences in
course delivery, the following steps were taken:
1. Both instructors have approximately the same amount of
experience (several years) teaching computer programming (and OO
programming) in the CIS Department at MSU.
2 The instructors selected two different texts written by the same
author (Gaddis, 2008a; Gaddis, 2008b). The only significant difference
between the two texts is the ordering of the chapters, one presenting
objects and classes in the early chapters while the other doing so in
the later chapters. These two texts were designed specifically by Gaddis
to support either an OF or a SF approach to teaching OO programming
using Java. The reading material, examples, and end-of-chapter problems
throughout the texts are essentially the same with the exception of the
ordering of the chapters.
3 Both instructors carefully planned the delivery of material (such
as chapters covered, assignment problems, and exam questions) to exactly
match in both sections (OF and SF) with the only difference being the
textbooks used.
4. Both instructors taught their respective sections in the same
lab setting using similar lecture/discussion/demonstration techniques
while assisting students in writing programs during specified lab time.
No graduate assistants were used in the delivery of these courses or in
the grading of assignments and exams. The instructors were in total
control of these courses.
5. Both instructors communicated with each other frequently during
the semester to ensure that they were on track with the plan to deliver
the same material in the same manner, with the exception of the OF and
SF approaches.
6. Both instructors consulted to design all items (multiple choice
and coding exercises) on the performance exams in the courses. The
specific criteria used to grade programs submitted by the students were
carefully chosen by both instructors together. Students in the different
sections were given the same items on exams.
7. Both instructors graded exams taken by the students (to assess
performance) together, constantly consulting with each other on how to
apply the predetermined criteria to individual programs submitted by
students on the exams.
As can be seen, the instructors were extremely careful to try to
eliminate any built-in bias in the delivery of the two courses. The only
significant variable in the two sections was whether OO programming
concepts and techniques were delivered before basic programming
structures (OF) or after basic programming structures (SF).
STUDENT BACKGROUND AND DEMOGRAPHICS
Data about the students were also collected during the first week
of class to ensure that both groups (OF and SF) were similar in
background and ability. Students were given a survey to determine
demographic data such as gender, age, college class, major and minor
areas of study, background with Java and other programming languages,
background in using computers, and desire to learn computer programming.
The college GPA and ACT scores were also collected for all students.
PERFORMANCE MEASURES
Three exams were administered to each section of students during
the semester (Exam 1, Exam 2, and the final exam). Each exam consisted
of 25 multiple-choice questions that covered programming concepts and
one programming problem. Students were asked to write a complete Java
program on paper on each exam. The instructors thought it would be
better to have the students write programs on paper, instead of on a
computer, so that credit could be given for code that was close to
correct, although points were deducted for incorrect syntax or program
logic. (Incorrect syntax on the computer would result in failure to
compile and perhaps lead to students ceasing to write additional code.)
While three exams were administered to both the OF and SF sections,
only the first and last exams were used in this study because only these
two exams were identical for both sections. Exam 1 was the same for both
sections because it covered the first two chapters in both texts (basic
Java programming involving variables, simple algorithms, and the
sequence structure). Exam 2 was not used in this study because it
covered different material for each section. During this middle segment
of the courses, the OF section covered two chapters on objects and
classes while the SF section was covering decisions, loops, and methods.
Toward the end of the semester, the OF section was catching up on
programming structures while the SF section was catching up on objects
and classes. The final exam was identical for both groups, consisting of
multiple choice questions on OO concepts and an OO programming problem.
Thus, each exam had a concepts section (assessed via the
multiple-choice questions) and a techniques section (assessed via the
programming problem). Grading the multiple-choice items was easy but
much more care was required when grading the hand-written student
programs. As described earlier, the instructors worked together in
grading all programs by their respective students to ensure that a
consistent grading method was employed. This required very frequent
consultations between the instructors during the grading process.
Examples of some of the multiple-choice questions used on Exam 1
are given below:
1. A runtime error usually the result of a syntax error b) bad data
c) a compilation error d) a logical error
2. What is the value of z after the following statements have been
executed? int x = 4, y = 33; double z; z = (double) (y/x); a) 8.0 b) 4
c) 0 d) 8.25
Following is the programming problem on Exam 1:
Write a complete Java application that asks for the user's
name and age (in years). The program should then calculate the number of
years until the person can retire. Use JOptionPane dialog boxes for
input and output. Use a named constant for the retirement age of 65. Add
appropriate comments at the beginning of the program. Follow best
programming practices and Java programming conventions. (Note: This is
an example of a purely structured programming problem, not OO, used on
the first exam and represents a fairly simple task.)
Examples of some of the multiple-choice questions used on the final
exam are given below:
1. It is a common practice in OO programming to make all of a
class's a) fields private b) fields and methods public c) methods
private d) fields public
2. What is the value of z after the following statements have been
executed? Double x = 45678.259; DecimalFormat formatter = new
DecimalFormat("#,###,##0.00");
System.out.println(formatter.format(x)); a) 45,678.3 b) 45,678.26 c)
45678.259 d) 0,045,678.26
Following is the programming problem on the final exam:
Write two Java programs, Book.java and BookApp.java. Use
JOptionPane for input and output. The Book class has three instance
fields: bookID (integer), bookTitle (String), and bookPrice (double).
The Book class has a static field, TAX_RATE = 0.05, which is a named
constant. The Book class has two constructors: one has two parameters
only (theId and theTitle) while the other has three parameters (theId,
theTitle, and thePrice). The Book class has a method called
calculateTax() which usues TAX_RATE and bookPrice to return the tax on a
book. The Book class has a method called calculateFinalCose(), which
calculates the final price of the book to the customer (bookPrice +
tax). The Book class has get and set methods for all instance fields.
The BookApp class has a while loop that allows the user to continue to
create new book objects until indicating that the program should stop.
Within the while loop, the BookApp class gets input from the user for
bookId, bookTitle, and bookPrice, creates a Book object, calculates the
tax using the calculateTax() method and calculates the final cost using
the calculateFinalCost() method. Within the while loop, the BookApp
class displays all the information about the book object created
including the ID, title, price, tax, and final cost. (Note: This is an
example of the OO programming problem that all students of both
sections, OF and SF, took on a two-hour final exam, and is therefore
more involved than the programming problem used on the first exam).
As can be seen, the multiple-choice questions on Exam 1 involve
only basic programming concepts and the programming problem on Exam 1 is
a straightforward and procedural. However, the final exam
multiple-choice questions involve understanding important OO concepts
(public and private class members, the new operator, and an object
calling a method). The OO programming problem on the final exam involves
writing a class used to create objects (containing instance fields,
constructors, and methods) and writing an application class that creates
objects, calls instance methods, and produces output.
DATA
Table 1 shows results of various demographic data for the OF and SF
groups as well as the results from Exam 1 and the final exam. Where
appropriate, small-sample T-tests for equivalent means were performed:
DISCUSSION
The data in Table 1 provide several interesting results.
Demographically, items 1-15 demonstrate that the two sections of
students are extremely similar. The distribution of males and females is
nearly identical and the mean ages are statistically the same. Items 5-6
show that the prior abilities of the two groups are also statistically
equivalent. Items 7-10 illustrate that the distribution of students by
class is nearly the same for both groups while items 11-12 reveal that
the distribution of CIS and non-CIS majors is nearly the same.
(Statistical tests for equivalent distributions were not performed, but
casual inspection largely supports these conclusions.) Items 13-15 point
to the fact that both groups have similar backgrounds with computers and
motivation for taking introductory Java programming.
The exam results are found in items 16-19. These are the results of
the first exam and the final exam for both groups. Recall that both of
these exams were identical for both groups of students. Exam 1 covered
Java programming basics such as Java syntax, variables, and simple
algorithms. The final exam involved object-oriented concepts and
programming techniques. The multiple choice items on these exams tested
for the understanding of programming concepts while the programming
problem tested for knowledge of writing correct code for complete
applications. The results show that both groups, OF and SF, were
statistically equivalent in all areas except that of actual OO
programming. The OF group averaged significantly higher on the
programming segment of the final exam.
Items 16-19 in Table 1 do appear to illustrate an interesting
trend. Item 16 shows that both groups were virtually equivalent in their
understanding of basic introductory Java programming concepts. However,
item 17 shows a slight weakness in the SF group. Keep in mind that both
groups covered exactly the same material prior to Exam 1. It could be
the case that the SF group did have some inherent weaknesses compared to
the OF group initially, resulting in a lower mean for the Exam 1
programming segment, although the difference was not statistically
significant. The difference between the two groups grew larger by the
end of the course when the final exam was administered. The SF group did
have a lower mean score on the concepts segment of the final exam,
although not statistically significant. But statistical significance was
apparent on the programming segment of the final exam.
While these results could be explained by some variation in the
delivery of the courses by the two different instructors, such variation
was minimized by taking measures to ensure a high degree of consistency.
It is much more likely that the early objects approach was instrumental
in the higher scores for the OF group on the final exam. If for no other
reason, the OF group was exposed to the concepts and techniques of OO
programming for several more weeks than the SF group. It could be the
case that over time, the SF group could master OO programming as well as
the OF group. However, within the short confines of a first course in
Java programming, an OF approach could result in greater success for the
student.
CONCLUSION
Learning programming is not an easy task for the novice student.
Learning OO programming is an even more daunting task. This study
compared the performance of two nearly identical groups of introductory
programming students. One group studied objects and classes very early
in the semester (the objects-first, or OF, group) while the other group
studied the basic programming structures (sequence, selection, and
repetition) before objects and classes (the structures-first, or SF,
group). Both groups took the same first exam (covering only basic Java
programming) before they diverged into either the OF or SF approaches.
Then both groups took the same final exam which covered full OO
development. The OF and SF groups were statistically identical in their
performance on the first exam, but the OF group performed significantly
better on the programming segment of the final exam. These experimental
results point to the possible superiority of an objects first approach
to teaching novice programming students, which may lead to higher
performance levels in subsequent programming courses and enhanced career
opportunities.
REFERENCES
Ragonis, N. & M. Ben-Ari (2005). A Long-Term Investigation of
the Comprehension of OOP Concepts by Novices. Computer Science
Education, 15 (September 2005), 203-221.
Sheetz, S., G. Irwin, D. Tegarden, J. Nelson, & D. Monarchi, D.
(1997). Exploring the Difficulties of Learning Object-Oriented
Techniques. Journal of Management Information Systems, 14 (Fall 1997)
103-131.
Thramboulidis, K., (2003). A Constructivism-Based Approach to Teach
Object-Oriented Programming. Journal of Informatics Education and
Research, 5 (Spring 2003) 1-14.
Richard A. Johnson, Missouri State University
Duane R. Moses, Missouri State University
Table 1: Means and hypothesis tests for the objects-first (OF)
section and the structures-first (SF) section
Objects- Structures-
first first
1 # Male 22 20
2 # Female 3 4
3 Total students 25 24
4 Age 20.8 21.0
5 Previous GPA 3.00 2.99
6 ACT score 24.1 23.7
7 # Freshmen 0 1
8 # Sophomores 10 14
9 # Juniors 12 7
10 # Seniors 3 2
11 # CIS majors 15 13
12 # Non-CIS majors 10 11
13 Previous college computer courses 1.36 1.29
14 I am comfortable using computers 4.13 * 4.68 *
15 This course is important to my career 3.43 * 3.41 *
16 Exam 1-Multiple Choice Items 83.3% 83.2%
17 Exam 1-Programming Problem 90.3% 85.9%
18 Final Exam-Multiple Choice Items 74.4% 66.6%
19 Final Exam-Programming Problem 87.9% 79.0%
t-value
1 # Male
2 # Female
3 Total students
4 Age -0.31
5 Previous GPA 0.12
6 ACT score 0.26
7 # Freshmen
8 # Sophomores
9 # Juniors
10 # Seniors
11 # CIS majors
12 # Non-CIS majors
13 Previous college computer courses 0.23
14 I am comfortable using computers
15 This course is important to my career
16 Exam 1-Multiple Choice Items 0.04
17 Exam 1-Programming Problem 1.18
18 Final Exam-Multiple Choice Items 1.66
19 Final Exam-Programming Problem 2.98
1 # Male [H.sub.0]:
2 # Female [[micro].sub.OF] =
3 Total students [[micro].sub.SF],
4 Age [alpha] =.05
5 Previous GPA
6 ACT score
7 # Freshmen
8 # Sophomores
9 # Juniors FTR [H.sub.0]
10 # Seniors FTR [H.sub.0]
11 # CIS majors FTR [H.sub.0]
12 # Non-CIS majors
13 Previous college computer courses
14 I am comfortable using computers
15 This course is important to my career
16 Exam 1-Multiple Choice Items
17 Exam 1-Programming Problem
18 Final Exam-Multiple Choice Items FTR [H.sub.0]
19 Final Exam-Programming Problem
FTR [H.sub.0]
FTR [H.sub.0]
FTR [H.sub.0]
Reject [H.sub.0]
[alpha] < .005
* Used a Likert scale of 1-5 for strongly agree to strongly disagree