Project management by ert554898



       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
  – 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
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 diagrams can show several different
  types of communication
  – E.g. method calls, messages send over the network
  – These are all referred to as messages
Elements Found in Interaction Diagrams

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

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

Class Diagram
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 box during the
     live 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
Sequence Diagrams

       Same example but with more details
Sequence Diagrams

• If an object’s life ends, this is shown with an X at the
  end of the lifeline
 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

     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)
UML Diagrams
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
  – Reacting to events and to messages received by the object
  – Triggering actions and sending messages to other objects
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
• 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

• 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
• Object deletion may be related with (one or many)
  final states
Sample State Diagram

• An event is something worth noticing at a point of
  – 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”)

• 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

• 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

 Draw a state diagram that shows the behavior of instances of
 the CourseSection class in the following class diagram:

                    (DONE IN CLASS)

To top