Java Reference
In-Depth Information
code duplication Code duplication (having the same segment of code in an application more
than once) is a sign of bad design. It should be avoided.
encapsulation Proper encapsulation in classes reduces coupling and thus leads to a better
design.
responsibility-driven design Responsibility-driven design is the process of designing
classes by assigning well-defined responsibilities to each class. This process can be used to
determine which class should implement which part of an application function.
localizing change One of the main goals of a good class design is that of localizing change:
making changes to one class should have minimal effects on other classes.
method cohesion A cohesive method is responsible for one, and only one, well-defined task.
class cohesion A cohesive class represents one well-defined entity.
refactoring Refactoring is the activity of restructuring an existing design to maintain a good
class design when the application is modified or extended.
switch statement A switch statement selects a sequence of statements for execution from
multiple different options.
Exercise 6.54 Without using BlueJ, edit your TechSupport project from Chapter 5 so that it
can execute without BlueJ. Then run it from a command line.
Exercise 6.55 Can you call a static method from an instance method? Can you call an
instance method from a static method? Can you call a static method from a static method?
Answer these questions on paper, then create a test project to check your answers and try it.
Explain in detail your answers and observations.
Exercise 6.56 Can a class count how many instances have been created of that class?
What is needed to do this? Write some code fragments that illustrate what needs to be done.
Assume that you want a static method called numberOfInstances that returns the number
of instances created.
Search WWH ::




Custom Search