Programming and Problem Solving with Java

(やまだぃちぅ) #1

316


for managing their own data and collaborating with other objects by invoking each
other’s methods.
Functional decomposition begins with an abstract solution that then is divided
into major steps. Each step becomes a subproblem that is analyzed and subdivided
further. A concrete step is one that can be translated directly into Java; abstract steps
need more refining. A module is a collection of concrete and abstract steps that
solves a subproblem.
A package collects a set of related classes into a common structure that can be
imported by other classes. The Java compiler allows just one publicclass per compi-
lation unit, so a package consists of multiple files, all of which begin with identical
packagestatements.
Careful attention to algorithm design, code formatting, and documentation
produces well-organized and readable programs that are easy to debug and
maintain.

Quick Check


1.Object-oriented design focuses on the _______ (nouns, verbs) when identifying
potential objects in a problem statement. (p. 270)
2.(True or False?) A class field is distinguished from an instance field by having
the modifier staticin its declaration (p. 273)
3.What Java construct do we typically use to implement a responsibility in a
class? (p. 280)
4.How do objects collaborate with each other? (p. 275)
5.A subclass may ___________ (import, inherit, construct) methods from its super-
class. (p. 285)
6.How many public classes may a compilation unit contain? (p. 295)
7.Can classes within the same package access each other’s fields that are at the
package level of access? (p. 295)
8.Name three ways that you can help to protect confidential data. (p. 302)
9.Class assignments are examples of programming in the _______ (small, large).
(p. 300)
10.(True or False?) In the initial brainstorming for an object-oriented design, as we
are generating ideas for candidate classes, we can simultaneously critique and
filter them. (pp. 277–278)
11.What happens in the filtering stage of a design? (pp. 278–280)
12.What do we write on a CRC card? (pp. 277–285)
13.Should the first scenario that you explore be a common case or one of the
exceptional cases? (pp. 280–285)
14.What is a collaboration between classes? (p. 275)
Free download pdf