Generating Source Code

 < Day Day Up > 



Creating Sequence Diagrams

Sequence diagrams are used to present views of dynamic message flow between system objects. You do not have to have all your classes and operations defined to create sequence diagrams, In fact, Describe™ will let you define new classes, and add new operations to existing classes, when you create sequence diagrams.

Proper Use of Sequence Diagrams

Sequence diagrams are most effective when they focus on one particular thread of application execution or functionality. A sequence diagram that attempts to model all the messaging in a large application would be very hard to read.

Adding Objects to Sequence Diagrams

Figure 20-19 shows the start of a sequence diagram for robot rat application launch.

click to expand
Figure 20-19: Start of Sequence Diagram for Robot Rat Application Launch

Objects are added to the sequence diagram by dragging them from the Systems Hierarchy pane, the large pane open to the left of the sequence diagram. Objects can also be added to the sequence diagram by selecting the desired object in the tool bar and adding it to the diagram.

If you have identified some or all of the classes for the system you are designing, they will be available in the System Hierarchy pane. If you add a new class to the sequence diagram, (a class that does not currently exist in your system), Describe™ will prompt you to add the new class to the current system if you desire. This is a good way to add classes to your design that you may not have thought of adding during the initial design phase.

In figure 20-19, the main application object, just to the right of the RobotRat User actor, represents the main.cpp file. I modeled the main.cpp file as an object in the system but chose not to add the main.cpp object to the system.

Adding Messages to Sequence Diagrams

Sequence diagrams model both outside actor interaction with an application and the interaction between application objects. Figure 20-19 shows the RobotRat User actor sending a Launch Application message to the main.cpp object. When the application is launched the main() function creates a new Controller object. This is indicated by the message labeled 1: Controller(). The number represents the message sequence; the name represents the object function name or operation.

To add a message to a sequence diagram click the message icon in the tool bar, click on the sequence diagram to indicate the message source, and finish by clicking on the diagram to indicate the message target. This action will result in a blank message line being generated from one object line to another. To add a name and other attributes to a message you can edit the message properties. Figure 20-20 shows the Properties Editor for the Controller() message sent from the main.cpp object to the controller object.

click to expand
Figure 20-20: Editing Controller() Message Properties

If you try and add a message to a sequence diagram and the target object does not yet declare the function, Describe™ will prompt you to add the operation to the target object. This is an excellent way to incrementally build your class interfaces.

Figure 20-21 shows the completed sequence diagram for the robot application start-up sequence.

click to expand
Figure 20-21: Completed Robot Rat Application Launch Sequence

Figure 20-21 shows the sequence of events from the time a user starts the robot rat application through to menu display and menu handling. This is an example of one particular thread of application execution. Other logical choices for sequence diagrams would be one for each of the robot rat user use cases shown in figure 20-9. For example, figure 20-22 shows the completed sequence diagram for the Create New RobotRat use case.

click to expand
Figure 20-22: Create New RobotRat Sequence Diagram

This sequence diagram, along with all supporting class diagrams, can be linked to the Create New RobotRat use case. See the Linking Diagrams section to learn how to link different diagram elements to use case diagrams.



 < 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