Java Reference
In-Depth Information
335
Chapter 8 Designing Classes
C HAPTER G OALS
ȗ
To learn how to choose appropriate classes to implement
ȗ
To understand the concepts of cohesion and coupling
ȗ
To minimize the use of side effects
ȗ
To document the responsibilities of methods and their callers with
preconditions and postconditions
ȗ
To understand the difference between instance methods and static methods
ȗ
To introduce the concept of static fields
ȗ
To understand the scope rules for local variables and instance fields
ȗ
To learn about packages
T To learn about unit testing frameworks
In this chapter you will learn more about designing classes. First, we will discuss
the process of discovering classes and defining methods. Next, we will discuss how
the concepts of pre- and postconditions enable you to specify, implement, and invoke
methods correctly. You will also learn about several more technical issues, such as
static methods and variables. Finally, you will see how to use packages to organize
your classes.
335
336
8.1 Choosing Classes
You have used a good number of classes in the preceding chapters and probably
designed a few classes yourself as part of your programming assignments. Designing
a class can be a challengeȌit is not always easy to tell how to start or whether the
result is of good quality.
Search WWH ::




Custom Search