Chapter 2. Study Guide

Although there are always some differences between any two programming languages, if we look at the family of imperative programming languages (including C++, Java, and C#), they are based on common concepts. So, while we focus on C++ and object-oriented programming this semester, you are also embarking on a broad, general study of computer science.

Most operators are essentially the same in the C++ and Java programming languages, and C++ functions are similar to Java methods. So, depending on what you studied in CS 1400 and how well you retain what you learned there, much of chapter 2 may be a review. Nevertheless, the chapter likely adds new operators and covers old ones in greater depth. So, you should review previously learned concepts and study new ones deeply.

Example Programs

Chapter 2 introduces a teaching and learning strategy that continues throughout the remainder of the textbook: example programs. While teaching a traditional face-to-face class, I frequently write programs and describe what each statement does and how it helps solve a given problem. Students write the programs with me, which helps them automate many of the steps required to write, organize, and compile C++ programs, and provides examples for later programming assignments. If you are in an online or flex class, writing the programs while watching the videos will provide you with the same benefits. Pause the video playback as needed to give yourself time to write the code.

Elaboration

Computer programs are abstract, so we need some way of understanding their behavior. I believe that we learn to program by first learning how to read and understand existing code. Greeno, Collins, & Resnick (1996) observe that "Research comparing excellent adult learners with less capable ones also confirmed that the most successful learners elaborate what they read and construct explanations for themselves" (p. 19). "Elaborate" and "construct explanations" are useful terms for instructional theorists, but they are of little use to students studying computer programming. We can tailor elaboration to programming by recognizing that every program solves a problem and then asking ourselves four questions about each statement in the program:

  1. What does this statement do?
  2. How does this statement connect with and help solve the problem?
  3. Could this statement be written in a different way?
  4. Does this statement need to be here or can I move it?
Elaboration is a skill that you must learn and practice. It is easier to start with the small, simple programs early in the text than with the larger, complex programs appearing later in the text. This chapter has several versions of the ftoc.cpp program that demonstrate my elaborations. Please see Learning for more detail.

Know