12.7. The Font Class

 
[Page 390 ( continued )]

11.7. (Optional) Modeling Dynamic Behavior Using Sequence Diagrams and Statecharts

The UML diagrams presented so far describe the properties and methods of a class or the static relationships among classes. This section introduces the sequence diagrams and statechart diagrams that model the dynamic behaviors of objects.

11.7.1. Sequence Diagrams

Sequence diagrams describe interactions among objects by depicting the time-ordering of method invocations. A sequence diagram consists of the following elements, as shown in Figure 11.14:

  • Class role represents the roles the object plays. The objects at the top of the diagram represent class roles.

  • Lifeline represents the existence of an object over a period of time. A vertical dotted line extending from the object is used to denote a lifeline.


    [Page 391]
  • Activation represents the time during which an object is performing an operation. Thin rectangles placed on lifelines are used to denote activations.

  • Method invocation represents communication between objects. Horizontal arrows labeled with method calls are used to denote method invocations.

Figure 11.14. Sequence diagrams describe interactions between objects.
(This item is displayed on page 390 in the print version)

The interactions among the objects in the BorrowLoan class on page in Listing 11.5 are illustrated in Figure 11.15.

Figure 11.15. The BorrowLoan object invokes the methods in the Name , Address , Loan , and Borrower objects.

11.7.2. Statechart Diagrams

Statechart diagrams describe the flow of control of an object. A statechart diagram contains the following elements, as shown in Figure 11.16:

  • State represents a situation during the life of an object in which it satisfies some condition, performs some action, or waits for some event to occur. All states have names . States are denoted by rectangles with rounded corners, except for the initial state, which is denoted by a small filled circle.

  • Transition represents the relationship between two states, indicating that an object will perform some action to transfer from one state to the other. A solid arrow with appropriate method invocation denotes a transition.

Figure 11.16. Statechart diagrams describe the flow of control of an object.



[Page 392]

The life cycle of an object can be illustrated using a statechart diagram, as shown in Figure 11.17.

Figure 11.17. The life cycle of an object can be described using a statechart diagram.

 


Introduction to Java Programming-Comprehensive Version
Introduction to Java Programming-Comprehensive Version (6th Edition)
ISBN: B000ONFLUM
EAN: N/A
Year: 2004
Pages: 503

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net