intTypePromotion=1
zunia.vn Tuyển sinh 2024 dành cho Gen-Z zunia.vn zunia.vn
ADSENSE

Bài giảng Phân tích thiết kế phần mềm: Chương 6 - Trường ĐH Ngoại ngữ - Tin học TP.HCM

Chia sẻ: _ _ | Ngày: | Loại File: PDF | Số trang:12

23
lượt xem
11
download
 
  Download Vui lòng tải xuống để xem tài liệu đầy đủ

Bài giảng Phân tích thiết kế phần mềm: Chương 6 cung cấp cho người đọc những kiến thức như: Tương tác và đối tác tương tác; các mảnh kết hợp; hơn nữa các yếu tố ngôn ngữ; các loại sơ đồ tương tác khác. Mời các bạn cùng tham khảo!

Chủ đề:
Lưu

Nội dung Text: Bài giảng Phân tích thiết kế phần mềm: Chương 6 - Trường ĐH Ngoại ngữ - Tin học TP.HCM

  1. 2/28/2019 Content  Introduction  Interactions and interaction partners  Messages  Combined fragments  Branches and loops  Concurrency and order  Filters and assertions  Further language elements  Further types of interaction diagrams 2 1 Introduction Interaction Diagrams  Modeling inter-object behavior (mô hình hóa hành vi giữa các objs)  Dùng để biểu diễn tương tác = interactions between objects  Mô hình hóa các kịch bản chắc chắn  Interaction (tương tác)  Mô tả chuỗi giao tiếp ở các mức độ chi tiết khác nhau  Specifies how messages and data are exchanged between interaction partners  Interaction Diagrams show the following:  Interaction partners (đối tượng tương tác)  Giao tiếp giữa 1 hệ thống và môi trường  Human (lecturer, administrator, …)  Giao tiếp giữa các thành phần của hệ thống để thể hiện cách một use  Non-human (server, printer, executable software, …) case có thể hiện thực  Examples of interactions  Giao tiếp giữa các tiến trình trong đó các thành tố thực hiện một giao  Conversation between persons thức.  Message exchange between humans and a software system  Giao tiếp giữa các cấp lớp (phép gọi hàm, hành vi tương giữa đối tượng)  Communication protocols  Sequence of method calls in a program  … 3 4 1
  2. 2/28/2019 Sequence Diagram Interaction Partners  Two-dimensional diagram  Interaction partners are depicted as lifelines  Horizontal axis: involved interaction partners  Head of the lifeline  Vertical axis: chronological order (thứ tự thời gian) of the interaction  Rectangle that contains the expression roleName:Class  Interaction = sequence of event specifications  Roles are a more general concept than objects  Object can take on different roles over its lifetime  Body of the lifeline  Vertical, usually dashed line  Represents the lifetime of the object associated with it Head of the lifeline Body of the Lifeline 5 6 Exchanging Messages (1/2) Exchanging Messages (2/2) Order of messages:  Interaction: sequence of events … on one lifeline … on different lifelines  Message is defined via send event and receive event  Execution specification  Continuous bar »Happens before«  Used to visualize when an interaction partner executes some behavior … on different lifelines which exchange messages Send event Receive event Execution specification 7 8 2
  3. 2/28/2019 Messages (1/3) Messages (2/3)  Synchronous message (thông điệp đồng bộ)  Object creation (tạo obj)  Sender waits until it has received a response message  Dashed arrow before continuing  Syntax of message name: msg(par1,par2)  Arrowhead points to the head of the lifeline of the  msg: the name of the message object to be created  par: parameters separated by commas  Keyword new  Asynchronous message (thông điệp bất đồng bộ)  Sender continues without waiting for a response message  Object destruction (hủy obj)  Syntax of message name: msg(par1,par2)  Object is deleted  Response message (thông điệp phản hồi)  Large cross (×) at the end of the lifeline  May be omitted if content and location are obvious  Syntax: att=msg(par1,par2):val  att: the return value can optionally be assigned to a variable  msg: the name of the message  par: parameters separated by commas  val: return value 9 10 Messages (3/3) Combined Fragments  Found message (thông điệp từ vô danh)  Model various control structures  Sender of a message is unknown or not relevant  12 predefined types of operators  Lost message (thông điệp bị mất) Combined Fragment  Receiver of a message is unknown or not relevant  Time-consuming message (thông điệp tốn thời gian)  "Message with duration" Operator  Usually messages are assumed to be transmitted Operand without any loss of time  Express that time elapses between the sending and the receipt of a message Operand Operand 11 12 3
  4. 2/28/2019 Types of Combined Fragments alt Fragment Operator Purpose  To model alternative Branches and alt Alternative interaction (tương tác có thể lựa chọn) sequences loops opt Optional interaction (tương tác tùy chọn)  Similar to switch statement in loop Repeated interaction (tương tác lặp) Java break Exception interaction (tương tác ngoại lệ)  Guards are used to select the seq Weak order (lệnh yếu) one path to be executed Concurrency and order strict Strict order (lệnh mạnh)  Guards par Concurrent interaction (tương tác song song)  Modeled in square brackets critical Atomic interaction (tương tác đơn nguyên)  default: true  predefined: [else] ignore Irrelevant interaction (tương tác không phù hợp) Filters and assertions consider Relevant interaction (tương tác phù hợp)  Multiple operands assert Asserted interaction (tương tác chèn)  Guards have to be disjoint to neg Invalid interaction (tương tác không hợp lệ) avoid indeterministic behavior 13 14 opt Fragment loop Fragment  To model an optional  To express that a sequence is to be executed repeatedly sequence  Exactly one operand  Actual execution at runtime  Keyword loop followed by the minimal/maximal number of iterations is dependent on the guard (min..max) or (min,max)  Exactly one operand  default: (*) .. no upper limit  Similar to if statement  Guard without else branch  Evaluated as soon as the minimum number of iterations has taken place  equivalent to alt fragment  Checked for each iteration within the (min,max) limits with two operands, one of  If the guard evaluates to false, the execution of the loop is terminated which is empty Max Min Guard Notation alternatives: loop is loop(3,8) = loop(3..8) executed at loop(8,8) = loop (8) least once, then loop = loop (*) = loop(0,*) as long as a
  5. 2/28/2019 break Fragment loop and break Fragment - Example  Simple form of exception handling  Exactly one operand with a guard  If the guard is true:  Interactions within this operand are executed  Remaining operations of the surrounding fragment are omitted  Interaction continues in the next higher level fragment  Different behavior than opt fragment Not executed if break is executed 17 18 seq Fragment seq Fragment – Example  Default order of events  Weak sequencing: 1. The ordering of events within each of the operands is maintained in the result. 2. Events on different lifelines from different operands may come in any order. 3. Events on the same lifeline from different operands are ordered such that an event of the first operand comes before that of the second operand. 19 20 5
  6. 2/28/2019 strict Fragment strict Fragment - Example  Sequential interaction with order  Order of event occurrences on different lifelines between different operands is significant  Messages in an operand that is higher up on the vertical axis are always exchanged before the messages in an operand that is lower down on the vertical axis 21 22 par Fragment par Fragment - Example  To set aside chronological order between messages in different operands  Execution paths of different operands can be interleaved  Restrictions of each operand need to be respected  Order of the different operands is irrelevant  Concurrency, no true parallelism 23 24 6
  7. 2/28/2019 Coregion Coregion – Example  To model concurrent events of a single lifeline  Order of event occurrences within a coregion is not restricted  Area of the lifeline to be covered by the coregion is marked by square brackets rotated by 90 degrees Impact of coregion Coregion 25 26 critical Fragment critical Fragment - Example  Atomic area in the interaction (one operand)  To make sure that certain parts of an interaction are not interrupted by unexpected events  Order within critical: default order seq 27 28 7
  8. 2/28/2019 ignore Fragment consider Fragment  To indicate irrelevant messages  To specify those messages that are of particular importance for the  Messages may occur at runtime but have no further significance interaction under consideration  Exactly one operand  Exactly one operand, dual to ignore fragment  Irrelevant messages in curly brackets after the keyword ignore  Considered messages in curly brackets after the keyword consider 29 30 ignore vs. consider assert Fragment  To identify certain modeled traces as mandatory  Deviations that occur in reality but that are not included in the diagram are not permitted  Exactly one operand 31 32 8
  9. 2/28/2019 neg Fragment Interaction Reference  To model invalid interactions  Integrates one sequence diagram in another sequence diagram  Describing situations that must not occur  Exactly one operand  Purpose  Explicitly highlighting frequently occurring errors  Depicting relevant, incorrect sequences 33 34 Gate Continuation Marker  Allows you to send and receive messages beyond the boundaries of  Modularizes the operands of an alt fragment the interaction fragment  Breaks down complex interactions into parts and connect them to one another with markers  Start marker points to target marker  No return to the start marker (in contrast to an interaction reference) Target marker Start marker 35 36 9
  10. 2/28/2019 Local Attributes and Parameters Time Constraints  Every sequence diagram is enclosed by a rectangular frame with a  Types small pentagon in the upper left corner  Point in time for event  Keyword sd, name of the sequence diagram, parameters (optional) occurrence  Relative: e.g., after(5sec)  Example: void func (int par1, int par2) {  Absolute: e.g., at(12.00) int x = 0;  Time period between two events String y = "Test";  {lower..upper} ...  E.g., {12.00..13.00} }  Predefined actions  now: current time Option 1: Parameter Option 2:  Can be assigned to an attribute and then used in a time constraint  Duration: calculation of the Local duration of a message attributes transmission 37 38 State Invariant Four Types of Interaction Diagrams (1/4)  Asserts that a certain condition must be fulfilled at a certain time  Based on the same concepts  Always assigned to a specific lifeline  Generally equivalent for simple interactions, but different focus  Evaluation before the subsequent event occurs  If the state invariant is not true, either the model or the implementation  Sequence diagram is incorrect  Vertical axis:  Three alternative notations: chronological order  Horizontal axis: interaction partners 39 40 10
  11. 2/28/2019 Four Types of Interaction Diagrams (2/4) Four Types of Interaction Diagrams (3/4)  Communication diagram  Timing diagram  Models the relationships between communication partners  Shows state changes of the interaction partners that result from the  Focus: Who communicates with whom occurrence of events  Time is not a separate dimension  Vertical axis: interaction partners  Message order via decimal classification  Horizontal axis: chronological order 41 42 Four Types of Interaction Diagrams (4/4) Notation Elements (1/2)  Interaction overview diagram Name Notation Description  Visualizes order of different interactions  Allows to place various interaction diagrams in a logical order Interaction partners involved in Lifeline the communication  Basic notation concepts of activity diagram Destruction Time at which an interaction partner event ceases to exist Combined Control constructs fragment 43 44 11
  12. 2/28/2019 Notation Elements (2/2) Name Notation Description Synchronous Sender waits for a response message message Response Response to a synchronous message message Sender continues its own work Asynchronous after sending the asynchronous communication message Lost message Message to an unknown receiver Message from an unknown Found message sender 45 46 12
ADSENSE

CÓ THỂ BẠN MUỐN DOWNLOAD

 

Đồng bộ tài khoản
5=>2