1. Trang chủ
  2. » Công Nghệ Thông Tin

Hiểu biết về mô hình hóa động pptx

50 231 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 50
Dung lượng 1,01 MB

Nội dung

Understanding Dynamic Modeling Chapter 7 An object-oriented design should represent the structural and behavioral aspects of a software system. Static modeling is used to represent the structural constituents of a software system. Dynamic modeling is used to represent the behavior of the structural constituents. Dynamic modeling uses various types of diagrams, such as interaction, state, and activity diagrams. This chapter explains the concept of dynamic modeling. In addition, it explains how to create the dynamic model of a system by using interaction diagrams. In this chapter, you will learn to:  Identify the concepts of dynamic modeling  Create interaction diagrams Objectives ¤NIIT Understanding Dynamic Modeling 7.3 Dynamic modeling is a UML modeling technique that represents the behavior of the static constituents of a software system. Therefore, it is also known as behavioral modeling. A designer requires dynamic modeling techniques to represent the interaction, workflow, and different states of the static constituents in a software system. The design of a software system is considered to be the good if it is able to represent what a system should do and how. Without a good design a developer will not be able to code a program correctly. This is because coding involves the implementation of the design. Modeling techniques are required to represent all aspects of a software system. These modeling techniques help in representing the system requirements, the static constituents of a system, its behavior, and architecture. Dynamic modeling techniques help the designer to represent the behavior of the static constituents so that a developer is able to depict how a system should behave to meet the desired requirements. It provides various diagrams such as, interaction, activity, and state diagrams, which help you design the dynamic model of a software system. Consider the example of Wilson Inc., an automobile manufacturing company, which is planning expansion and, for this reason, wants to automate its inventory control. The management of Wilson Inc. decides to install an inventory management system (IMS) that will organize the stock reorder level, supplier details, and payments for spare parts records. The task of developing the IMS is entrusted upon a development team that creates a dynamic model of the IMS to understand the interaction between the various components of the software system. The dynamic model of the IMS is created using various diagrams, such as interaction, state, and activity diagrams. The interaction diagram models the interaction between the static constituents of a software system. The activity diagrams represent the sequence of activities that the static constituents of a system need to perform to complete a process and the state diagrams depict the changes that occur in the state of objects because of the interaction among the various constituents of a software system. Introducing Dynamic Modeling Concepts Need for Dynamic Modeling 7.4 Understanding Dynamic Modeling ¤NIIT Static modeling is required to represent the physical structure of a software system. However, it is insufficient as it does not explain how the constituents of the structure behave and interact with each other. To depict the behavior of the structural constituents, you need dynamic modeling. The following table lists the differences between static and dynamic modeling. Static Modeling Dynamic Modeling It represents the static or structural constituents of a software system. Therefore, it is also known as structural modeling. It represents the behavior of static constituents of a software system. Therefore, it is also known as behavior modeling. It includes class and object diagrams. It includes interaction, activity, and state diagrams. It helps in depicting the relationships and dependencies between the constituents of a system. It helps in expressing and modeling the behavior of a system over a period of time. Difference between Static and Dynamic Modeling Difference between Static and Dynamic Modeling ¤NIIT Understanding Dynamic Modeling 7.5 N ote Interaction diagrams depict how the constituents of a software system interact to realize the use cases of the system. In addition, you can use interaction diagrams to generate executable code through forward and reverse engineering. The two components of an interaction diagram are:  Collaboration: Depicts the static aspect of an interaction diagram.  Interaction: Depicts the dynamic aspect of an interaction diagram. A collaboration is a collection of instances of classes, the relationship among the instances of classes, and actors. A collaboration groups all the components that are required to realize a use case. The relationships among the components of a collaboration are graphically depicted as links between objects. A link serves as a path over which messages are sent and received. Although, abstract classes and interfaces do not have instances, they can form a part of a collaboration. You use interactions to depict the flow of control in an operation or among use cases. In an interaction, an object sends a message to request another object to perform an operation. In other words, an interaction is initiated when one object requests another object to perform certain operations, and in this way, invokes its methods. For example, Wilson Inc. has an inventory database that stores the inventory information when a new stock of automobile parts arrives. The inventory manager intimates the supplier and orders automobile parts when the stock of a part reaches its reorder level. To design the IMS, the development team creates a collaboration for the use case, order parts, which is realized through the interaction of Order object and the inventory database. The various interactions to realize the use case, order parts are: 1. Request by the Inventory Manager actor to the object, O1 of class Order, to perform the operation, issueOrder(). 2. Request by the issueOrder() operation to the database to store the information about the order. 3. Signal sent by the database to the object, O1, to intimate that the data storage operation is complete. Creating Interaction Diagrams 7.6 Understanding Dynamic Modeling ¤NIIT N ote The following figure shows the flow of control to realize the order parts use case of the IMS. Interaction Diagram for the Order Parts Use Case There are multiple slots in a collaboration, called roles, which are filled by objects and links at run time. In other words, roles are used to depict the run-time responsibility of the objects of a class and the relationship. The two types of roles in a collaboration are:  Classifier roles: Describe objects that can form a part of the collaboration.  Association roles: Describes the links that can form a part of the collaboration. An interaction signifies the collection of communications that occur among the classifier roles across the association roles. A collection of communications indicates the messages that flow from one classifier role to another. ¤NIIT Understanding Dynamic Modeling 7.7 When an object calls the methods of another object, a sequence of messages flow between them. The following table lists the various types of messages that can be sent from one object to another and their graphical representation in an interaction diagram. Message Description Graphical Representation Call Specifies the invocation of a method of an object. Return Returns a value to the calling method. Send Sends an asynchronous signal to an object. Create Creates an object. Destroy Destroys an object. The commonly used interaction diagrams are Sequence diagram and Communication diagram. Let us, discuss how to create these diagrams. Sequence diagrams represent an interaction among objects in the form of messages ordered in a sequence by time. In a sequence diagram, you arrange objects across the x-axis. You place the object that starts an interaction to the extreme left. The objects that come later in the message sequence are placed to the right of the interaction-initiating object. The messages sent and received by the objects in an interaction are placed along the y-axis in an increasing order of time. Creating Sequence Diagrams 7.8 Understanding Dynamic Modeling ¤NIIT The following figure depicts the arrangement of objects and messages in a sequence diagram. Arrangement of Messages and Objects in a Sequence Diagram An object may be created or destroyed when an operation is performed. You can use sequence diagrams to depict the creation and destruction of an object. In addition, sequence diagrams depict the change in the focus of control of an object in the form of a rectangular bar. The length of rectangle bar represents the duration of time for which an object interacts with another object. The following figure depicts a sequence diagram that shows how an object is created and destroyed, the focus of control, and the object lifeline. Focus of Control and Object Lifeline in a Sequence Diagram Object1 Ob j ect2 <<create>> Message <<destroy>> Focus of Control Object Lifeline ¤NIIT Understanding Dynamic Modeling 7.9 In the preceding figure, Object1 creates Object2 and subsequently sends a message to it. When Object2 completes its processing, it is destroyed. Consider the following sequence diagram for the Order Parts use case of the IMS system. Sequence Diagram for the Order Parts Use Case In the preceding figure, the Inventory Manager creates an instance of the order class and invokes the issueOrder() method of the order class. The order object stores the details in the Inventory Database. When the details are stored in the database, the order object receives a Transaction Complete signal and is then destroyed. When an object invokes its own method or receives a callback from another object, a new focus of control is represented over the existing focus of control and is called a nested focus of control. 7.10 Understanding Dynamic Modeling ¤NIIT N ote The following figure shows the nested focus of control of an object. Nested Focus of Control Unlike sequence diagrams, communication diagrams do not depict the object lifeline. In a sequence diagram, the flow of control depicts a sequential flow of messages. However, a programming logic may require you to depict the iterations of messages or the branching of the flow of control. Iterations are repetitions of messages. You can use the following statement to depict an iteration in a sequence diagram: *[ j := 1 n ] You use an asterisk, *, to indicate that the message is being sent repeatedly. You can depict iteration by using the following notations:  [j < 10]: Specifies that the message will be sent until the value of j is less than 10.  [val not found]: Specifies that the message will be sent until val is found.

Ngày đăng: 12/08/2014, 18:21

TỪ KHÓA LIÊN QUAN

w