1 / 22

CSCI-383

CSCI-383. Object-Oriented Programming & Design Lecture 12. UML Diagrams. Interaction Diagrams. Interaction diagrams are used to model the dynamic aspects of a software system They help you to visualize how the system runs

angiemccray
Download Presentation

CSCI-383

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSCI-383 Object-Oriented Programming & Design Lecture 12

  2. UML Diagrams

  3. Interaction Diagrams • Interaction diagrams are used to model the dynamic aspects of a software system • They help you to visualize how the system runs • An interaction diagram is often built from a use case and a class diagram • The objective is to show how a set of objects accomplish the required interactions with an actor

  4. Interactions and Messages • Interaction diagrams show how a set of actors and objects communicate with each other to perform • The steps of a use case, or • The steps of some other piece of functionality • The set of steps, taken together, is called an interaction • Interaction diagrams can show several different types of communication • E.g. method calls, messages send over the network • These are all referred to as messages

  5. Elements Found in Interaction Diagrams • Instances of classes • Shown as boxes with the class and object identifier underlined • Actors • Use the stick-person symbol as in use case diagrams • Messages • Shown as arrows from actor to object, or from object to object

  6. Creating Interaction Diagrams • You should develop a class diagram and a use case model before starting to create an interaction diagram • There are two kinds of interaction diagrams: • Sequence diagrams • Communication diagrams

  7. Sequence Diagrams Sequence Diagram Class Diagram

  8. Sequence Diagrams • A sequence diagram shows the sequence of messages exchanged by the set of objects performing a certain task • The objects are arranged horizontally across the diagram • An actor that initiates the interaction is often shown on the left • The vertical dimension represents time • A vertical line, called a lifeline, is attached to each object or actor • The lifeline becomes a broad box, called an activation boxduring thelive activation period • A message is represented as an arrow between activation boxes of the sender and receiver • A message is labelled and can have an argument list and a return value

  9. Sequence Diagrams Same example but with more details

  10. Sequence Diagrams • If an object’s life ends, this is shown with an X at the end of the lifeline

  11. Exercise Suppose that we are developing a loan processing system and we have identified the following use case: Use case: Submit Loan Request Actors: Applicant, Credit Bureau Steps: 1. An applicant completes and submits a loan application to the bank via the Internet. 2. The system validates the information on the loan application, checking that it is correct and as complete as possible. 3. The system forwards a loan request to an external credit bureau for a credit report on the applicant. 4. The system calculates the applicant’s credit score based on the returned credit report. Draw a corresponding sequence diagram (DONE IN CLASS)

  12. UML Diagrams

  13. State Diagrams • State diagrams are a technique to describe the behavior (i.e., state changes) of a single object according to events and messages which the object sends and receives • How does an individual object interact with other objects? • Reacting to events and to messages received by the object • Triggering actions and sending messages to other objects

  14. State Diagrams • State diagrams are good at describing the behavior of an individual object across several use cases • Draw state diagrams especially for classes that are not well understood and that need detailed description • State diagrams are not very good at describing behavior that involves a number of objects collaborating together • If you have to describe several objects, which are involved in a single use case, use interaction diagrams instead

  15. States • A state • Represents the internal condition/state of an object for a certain period of time • Corresponds to an interval of time between 2 events • The response to events may depend on the state of an object • Object creation comes together with an initial object state • Object deletion may be related with (one or many) final states

  16. Sample State Diagram

  17. Events • An event is something worth noticing at a point of time • A signal from one object to another (e.g., “delivered”) • A message received by an object (e.g., “check item”) • A certain date/time (e.g., “after 10 seconds” of being in a certain state or “at 31-dec-2000, 00:00”) • Events may take arguments (e.g., “deliver to receiver: Customer”)

  18. Transitions • A transition represents a change of the internal condition/state of an object • A transition is usually triggered (“fired”) by an event. Transitions without event label (“lambda transitions”) fire immediately • Transitions fire instantly • From exactly one state to another state or to itself (self-transition) and are not interruptible

  19. Transitions

  20. Guards • A guard is a logical condition (i.e., value is either “true” or “false”) • A guarded transition fires only if the guard resolves to “true” • Since only one transition can be fired in a given state, guards are intended to be mutually exclusive for any event • Events may be guarded

  21. Guards

  22. Exercise Draw a state diagram that shows the behavior of instances of the CourseSection class in the following class diagram: (DONE IN CLASS)

More Related