Java Reference
In-Depth Information
CHALLENGE 9.5
Fill in the messages in Figure 9.5.
Figure 9.5. MVC causes calls to pass from a GUI layer into a business layer and
back into the GUI layer.
The payback for a layered design is in the value of the interface and in the independence that
you get between the layers. The layering of code is a layering of responsibility, which makes
the code easier to maintain. For example, in the ballistics example, you can add a second GUI,
perhaps for a handheld device, without having to change classes in the business object layer.
In the business object layer, you might add a new source of change that updates a
Tpeak
object. In this case, the O
BSERVER
mechanics you have in place will automatically update
objects in the GUI layer.
Another advantage of layering code is that layering supports a move to an
n
-tier architecture,
with layers executing as tiers on different computers. This minimizes the amount of code that
must execute on a user's desktop. It also lets you make changes in business classes without
updating software on user machines, greatly simplifying deployment.
In short, O
BSERVER
supports MVC. MVC supports
n
-tier computing, which brings many
practical advantages to software development and deployment.
Maintaining an Observable Object
You may not always be able to make the class you want to observe a subclass of
Observable
. In particular, your class may already be a subclass of something other than
Object
. In this case, you can provide your class with an
Observable
object and have your