Java Reference
In-Depth Information
SOLUTION 10.2
Your solution should look something like Figure B.13. Note that although this diagram shows
only a Tub domain object, the mediator must also update the affected machines when a user
moves a tub.
Figure B.13. When you move event handling into a mediator class, components register
a mediator object for their events. When a user clicks a button, the event goes to
the mediator, where domain-specific knowledge about the action to perform resides.
SOLUTION 10.3
Figure B.14 shows an updated object diagram. The problem that the developer's code
introduces is that StarPress-2402 still thinks that it has tub T308 . In a relational table,
changing the machine attribute of a row automatically removes the tub from the prior
machine. This automated removal does not occur when the relation is dispersed across
a distributed object model. The proper modeling of the tub/machine relation requires special
logic that you can remove to a separate mediator object.
Figure B.14. Two machines think that they contain tub T308. The object model accepts
a situation that neither a relational table nor reality will allow.
Search WWH ::




Custom Search