Sequence Diagrams

 < Day Day Up > 



UML sequence diagrams are a great way to show graphically the order of object messaging activity in an application. Figure 12-4 shows a sequence diagram illustrating the messaging between the main() function, class B object b1, and class A a object a1 as shown in the code example 12.12.

click to expand
Figure 12-4: UML Sequence Diagram Illustrating Message Passing Between Objects

The main() function creates an A object and by doing so calls the A constructor. This is shown as an A() message being sent from main() to the a1 object. The result of the constructor call is the constructor message which is shown in the sequence diagram as a message from a1 back to the main() function labeled Constructor Message. Next, the b1 object is created in similar fashion. Once the b1 object is created the main() function sends it the makeContainedObjectSayHi() message. The b1 object processes this message by sending the sayHi() message to the a1 object (via the pointer). When the program terminates the destructors are called on the a1 and b1 objects. This is not shown in the diagram.

Quick Summary

There are two forms of aggregation: simple and composite. In simple aggregation the whole object does not control the lifetime of its part objects. This means that part objects could play a role in more than one aggregate relationship. In composite aggregation the whole object controls the lifetime of its part objects. This means it controls their creation and destruction. Composite aggregates can be formed from simple part objects, part objects allocated dynamically, or from a combination of both. Composite aggregates control the lifetimes of their part objects; simple aggregates do not.

The UML class diagram can be used to illustrate aggregate relationships. A line between classes denotes an association. A diamond is placed at the composite end of the association line denoting aggregation. A hollow diamond indicates simple aggregation; a solid diamond indicates composite aggregation.

The UML sequence diagram is used to illustrate message passing between objects.



 < Day Day Up > 



C++ for Artists. The Art, Philosophy, and Science of Object-Oriented Programming
C++ For Artists: The Art, Philosophy, And Science Of Object-Oriented Programming
ISBN: 1932504028
EAN: 2147483647
Year: 2003
Pages: 340
Authors: Rick Miller

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