Programming and Problem Solving with Java

(やまだぃちぅ) #1
Preface | xvii

these concepts. We close the chapter with a discussion of class and method construction, in-
cluding writing a very simple value-returning method. The case study results in a Java ap-
plication that contains a class for a name object, including several simple methods.
InChapter 3,we turn to the numeric types and expression syntax. We cover type conver-
sions, precedence rules, and the use of numeric types with String objects. We also reinforce
the distinction between the reference and primitive types in this chapter. We then see how
to develop an application with separately compiled classes, using the default anonymous
package. The case study then develops an employee object that imports a revised version of
the name class developed in Chapter 2. The result is a fairly sophisticated application that
appears simple and requires noticeably less work as a result of reuse.
With Chapter 4,we introduce the first variation in control flow, branching. The if-elsestate-
ment is introduced first as the general case and the ifstatement is then a special instance
of it. The Boolean type and expressions are covered extensively in preparation for branch-
ing. The concepts of encapsulation and abstraction are then introduced and motivate an
example in which the name class from the preceding two chapters is made more broadly ap-
plicable. It is then used in the case study, as part of developing a student record class that is
then used in a grade-notices application. This layered development of the name class, together
with its use in yet another context, helps to drive home the importance of object-oriented
design. The chapter closes with a discussion of testing strategies and formal test plans.
Chapter 5brings us to file I/O and loops. As in our other texts, we introduce all of the ba-
sic loop algorithms with one loop construct, the whileloop. We prefer to focus on how loops
are used in algorithms, while introducing only the minimum syntax necessary to illustrate
the concepts: count-controlled, event controlled, and various loop processes together with
a loop design methodology. In that way, students don’t develop the misperception that the
different forms of control structures are bound to the different syntactic structures in a lan-
guage. This approach also avoids the situation that we commonly see in which students are
focused on their confusion over choosing among different looping statements when they are
really still unsure of the underlying algorithmic mechanism that they wish to express.
Chapter 9 compares and contrasts the remaining looping structures with the whileloop,
once students have gained enough experience to be confident in their understanding of
how loops work. Chapter 5 also includes a discussion of mutable and immutable objects, and
this is then reinforced in the case study where we build a gender class that is mutable and
use it in an application.
Chapter 6takes a break from the introduction of significant amounts of new syntax and
focuses on object-oriented design using the CRC-card technique, which is one of the simpler
representations recognized by UML. The students learn how to brainstorm initial classes, fil-
ter the initial list, then develop the responsibilities and collaborations for these and other
classes that they discover through a series of scenarios. During this process, we give the stu-
dents an initial taste of the concept of inheritance. The only new Java syntax that we intro-
duce in Chapter 6 is the named package. The chapter also explores ethical issues in computing
before closing with a case study that builds two new classes, and reuses the name class in
order to construct an application that does the initial data entry for an address book.
Chapter 7is, in a sense, the core of the text. In this chapter, we bring together all of the dis-
cussion of classes and objects in the context of an object hierarchy with inheritance and poly-

Free download pdf