1. Object-Oriented Analysis and Design Using UML
Objectives
In this session, you will learn to:
Identify the concepts of dynamic modeling
Create interaction diagrams
Ver. 1.0 Slide 1 of 21
2. Object-Oriented Analysis and Design Using UML
Introducing Dynamic Modeling Concepts
Dynamic modeling depicts the behavior of the static
constituents of a software system, such as interaction,
workflow, and different states.
You depict the dynamic model of software system using:
• Interaction diagrams: Model the interaction between the
constituents of a software system, such as objects, interfaces,
and abstract classes.
• Activity diagrams: Represent the workflow between the static
constituents.
• State diagrams: Depict the changes that occur in the state of
objects because of the interaction among the various
constituents of a software system.
Ver. 1.0 Slide 2 of 21
3. Object-Oriented Analysis and Design Using UML
Difference between Static and Dynamic Modeling
Static modeling is required to represent the physical
structure of a software system.
Dynamic modeling depicts the behavior of the structural
constituents.
Static Modeling Dynamic Modeling
It represents the static or structural It represents the behavior of static constituents
constituents of a software system. of a software system.
It includes class and object diagram. It includes interaction, activity, and state
diagrams.
It helps in depicting the relationships and It helps in expressing and modeling the
dependencies between the constituents of behavior of a system over a period of time.
a system.
Ver. 1.0 Slide 3 of 21
4. Object-Oriented Analysis and Design Using UML
Creating Interaction Diagrams
Interaction diagrams:
Depicts how the constituents of a software system interact to
realize use cases of the system.
Can be used to generate executable code through forward and
reverse engineering.
Components of an interaction diagram are:
• Collaboration: Depicts the static aspect of an iteration
diagram.
• Interaction: Depicts the dynamic aspect of an iteration
diagram.
Ver. 1.0 Slide 4 of 21
5. Object-Oriented Analysis and Design Using UML
Creating Interaction Diagrams (Contd.)
Collaboration:
Is a collection of instances of classes, relationship among the
instances of classes, and actors.
Groups all those constituents that are required to realize a use
case.
Types of roles in a collaboration are:
• Classifier roles: Describes objects that can form a part of the
collaboration.
• Association roles: Describes links that can form a part of the
collaboration.
Interaction depicts 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.
Ver. 1.0 Slide 5 of 21
6. Object-Oriented Analysis and Design Using UML
Creating Interaction Diagrams (Contd.)
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 Specifies the invocation of a
method of an object.
Send Sends an asynchronous
signal to an object.
Create Creates an object.
Destroy Destroys an object.
Ver. 1.0 Slide 6 of 21
7. Object-Oriented Analysis and Design Using UML
Creating Interaction Diagrams (Contd.)
The commonly used interaction diagrams are:
Sequence diagrams
Communication diagrams
Ver. 1.0 Slide 7 of 21
8. Object-Oriented Analysis and Design Using UML
Creating Sequence Diagrams
Sequence diagram:
Represents an interaction among objects in the form of
messages ordered in a sequence by time.
The following figure depicts the arrangement of objects and
messages in a sequence diagrams.
Ver. 1.0 Slide 8 of 21
9. Object-Oriented Analysis and Design Using UML
Creating Sequence Diagrams (Contd.)
Guidelines for modeling sequence diagrams are:
Identify the collaboration for interaction in system, subsystem,
and use cases.
Identify the objects that have higher responsibility in the
interaction. Place the objects with high responsibility on one
side and the low responsibility objects on the other.
Identify the lifeline of each object in view of control to depict the
creation and destruction of an object.
Identify the messages that flow between the lifeline of objects.
Identify pre-conditions and post-conditions for each message
to control the flow of objects.
Ver. 1.0 Slide 9 of 21
10. Object-Oriented Analysis and Design Using UML
Creating Communication Diagrams
Communication Diagram:
Represent the interaction among objects in the form of
messages.
The following figure shows a communication diagram.
Ver. 1.0 Slide 10 of 21
11. Object-Oriented Analysis and Design Using UML
Creating Communication Diagrams (Contd.)
Guidelines for modeling a communication diagrams are:
Identify the collaboration that involves interaction in the
system, subsystem, and use cases.
Identify the objects that have higher responsibility in the
interaction. Draw these objects on a graph so that the objects
with high responsibility are placed on one side and the objects
with lower responsibility are placed on the other.
Identify the links between objects. You need to place the
association links for depicting the relationship among objects.
Identify all the messages that flow across the links established
among objects.
Ver. 1.0 Slide 11 of 21
12. Object-Oriented Analysis and Design Using UML
Assigning Responsibilities to Classes
Assigning responsibilities to a class or a set of classes
ensures that the software system has the desired
functionality as per the requirement document.
Decisions about responsibilities of classes are taken during
the creation of interaction diagrams.
A responsibility is implemented using methods of classes,
which may implement the entire responsibility or collaborate
with other methods.
Ver. 1.0 Slide 12 of 21
13. Object-Oriented Analysis and Design Using UML
Assigning Responsibilities to Classes (Contd.)
Guidelines for assigning responsibilities to objects are:
Assign responsibilities to classes such that they perform all
tasks that are performed by the real world entity it represents.
Assign responsibilities to a class if the class has the attributes
that will enable it to fulfill the responsibilities.
Assign responsibilities to multiple classes if all classes have
data to fulfill the responsibility.
Distribute responsibilities evenly to the various classes of your
software system.
Check that all classes of the software system have some
responsibility assigned to them. If no responsibility is assigned
to a class, you need to check if the class is required.
Ver. 1.0 Slide 13 of 21
14. Object-Oriented Analysis and Design Using UML
Assigning Responsibilities to Classes (Contd.)
Check if too many or unrelated responsibilities have been
assigned to a class. If such a class exists, split the class into
smaller classes.
Ver. 1.0 Slide 14 of 21
15. Object-Oriented Analysis and Design Using UML
Just a minute
Which of the following diagrams represents the interaction
among objects in the form of messages?
1. Composite structure diagrams
2. Communication diagrams
3. Timing diagrams
4. Interaction Overview diagrams
Answer:
Communication diagrams
Ver. 1.0 Slide 15 of 21
16. Object-Oriented Analysis and Design Using UML
Demo: Modeling the Dynamic View of the Bank ATM System
Problem Statement:
Janes Technology has been assigned the task of creating a
dynamic model of the prototype for the InfoSuper bank ATM
system. Janes Technology needs to implement only the cash
withdrawal system in the prototype for the InfoSuper bank. The
following table describes classes, attributes, and operations for
the cash withdrawal feature of the InfoSuper bank, which the
design team of Janes Technology has identified.
Class Operations Desciption
ATM Show() Displays the location and branch name of the ATM.
ATMCard GetPin() Accepts the PIN entered by the customer and
verifies it.
GetAccount() Fetches the account information based on the
card_ID and PIN.
SetPin(int)
Updates the PIN.
Ver. 1.0 Slide 16 of 21
17. Object-Oriented Analysis and Design Using UML
Demo: Modeling the Dynamic View of the Bank ATM System (Contd.)
Class Operations Desciption
BankCustomer InsertCard() Prompts the customer to insert ATM
card.
SelectTransaction() Select a transaction from a list of
transactions.
EnterPin()
Prompts the customer to enter PIN.
ChangePin() Invokes the PIN change request. Enters
the new PIN.
Invokes the cash withdrawal operation.
WithdrawCash()
RequestTransactionSummary() Requests for a transaction summary.
Account CalculateInterest() Calculates the interest for the account.
This is an abstract operation.
UpdateAccount() Updates the account information.
VerifiyWithdrawalAmount() Verifies if the amount to be withdrawn is
less than the account balance amount.
Ver. 1.0 Slide 17 of 21
18. Object-Oriented Analysis and Design Using UML
Demo: Modeling the Dynamic View of the Bank ATM System (Contd.)
Class Operations Desciption
CurrentAccount CalculateInterest() Calculates the interest for the current
account.
SavingsAccount CalculateInterest() Calculates the interest for the savings
account
Transaction getAccountBalance() Gets the balance of the account.
StartTransaction() Initiates the transaction.
CancelTransaction Cancels the transaction.
CardScanner AcceptCard() Accept/rejects the ATM card.
ReadCard() Reads the Card_Id associated with the
ATM card.
EjectCard() Ejects the ATM card.
Ver. 1.0 Slide 18 of 21
19. Object-Oriented Analysis and Design Using UML
Demo: Modeling the Dynamic View of the Bank ATM System (Contd.)
Class Operations Desciption
DisplayScreen Prompt() Prompts the respective screen as per request.
AcceptInput() Accepts the required input on the displayed
screen.
CashDispenser SupplyCash() Supplies the verified amount as cash.
GenerateRecipt() Generates a receipt for the cash dispensed.
The design team also created the following class diagram after
identifying the classes and operations for InfoSuper bank.
Class Diagram
Ver. 1.0 Slide 19 of 21
20. Object-Oriented Analysis and Design Using UML
Demo: Modeling the Dynamic View of the Bank ATM System (Contd.)
Solution:
To model the dynamic view of the cash withdrawal feature of
the ATM system, you need to perform the following tasks:
Identify the collaboration and interactions.
Create a sequence diagram.
Create a communication diagram.
Ver. 1.0 Slide 20 of 21
21. Object-Oriented Analysis and Design Using UML
Summary
In this session, you learned that:
Dynamic modeling is used to understand the interaction among
objects and the states of objects of software systems.
Interaction diagrams show an interaction between the objects
of a collaboration. Few interaction diagrams are: sequence and
communication.
Sequence diagram is a type of interaction diagrams that is
used to model the flow of control by time ordering.
Communication diagrams represent the interaction among
objects in the form of messages.
Ver. 1.0 Slide 21 of 21
Notas do Editor
Initiate the session by explaining the session objectives to the students. The concepts in this lesson are very theoretical. For this reason, an Inventory Management System case study has been used to explain the concepts. You need to build upon this case study so that the students can relate the concepts with real-life scenarios. An expansion of this case study that highlights the use of interaction and state diagrams is given in all the topics.
Explain the concept and need for dynamic modeling using the example of Inventory Management System (IMS) given in the students guide.
Explain the differences between static and dynamic modeling.
Explain the concept of interaction diagrams. Explain the two components of an interaction diagram.
Explain the concept of a collaboration and the type of roles in a collaboration. Also explain the concept of interactions.
Explain the different types of messages that can be sent from one object to another by using the graphical notations given on the slide.
Explain the four types of interaction diagrams.
Explain how to create sequence diagrams by using the example given on the slide. Explain how the creation and destruction of an object is depicted in a sequence diagram. Ask the students to create a sequence diagram for the Order Parts use case of the Inventory Management System. Explain nested focus of control and iteration is sequence diagrams. Also explain the branching of the object lifeline. Explain the concept of branching by using the sequence diagram for the Order Parts use case given in the student guide.
Explain the guidelines for modeling sequence diagrams.
Explain how to create a communication diagram by using the example given on the slide. Explain the numbering of messages in a sequence diagram. Ask the students to create the communication diagram for the Order Parts use case of the Inventory Management System. Explain the model solution by referring to the student guide. Explain how a communication diagram can be derived from a sequence diagram and vice-versa.
Explain the guidelines for modeling a communication diagram.
Explain the concept of assigning responsibilities to classes by using the example of the Inventory Management System given in the student guide. In addition, share the following additional inforamtion with the students. Class, Responsibility, Collaborations (CRC) cards are cards that help identify the responsibilities associated with a class and the classes that collaborate with the class to fulfill the responsibilities. A CRC card is a rectangle that is partitioned to form compartments. The first compartment contains the name of the class, the second compartment contains the responsibilities of the class and the third compartment contains the classes that collaborate with the class for which the CRC card is made. The following figure shows CRC cards that depict the responsibilities of the Supplier and Order classes to realize the Process Order use case of IMS. <<<<<<<<<<<<<<INSERT FIGURE>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<INSERT FIGURE>>>>>>>>>>>>>>>>> In addition, CRC cards help identify the classes that do not have any responsibilities to enable you to check the design of the classes of the software system. Therefore, you can eliminate the classes that do not participate in implementing any function of the software system.
Explain the guidelines for assigning responsibilities to classes.
Check the learning of the students by asking the question given on the slide.
Explain the problem statement to the students.
Before starting the demo, you need to copy the required data file from the <<<<<<<PATH>>>>>>>>>> folder. The required data file’s name is Bank_ATM.vsd. Demonstrate the solution to the problem statement by following the steps given in the student guide. If you want to show students the final diagram that will be created after performing the demo, you can open the Bank_ATM.vsd file from the <<<<<<<PATH>>>>>>>>> folder. The demo does not repeat similar steps. However, you would be able to complete the diagram with the steps written in the demo.
Summarize the session by using the summary points given on the slide.