Académique Documents
Professionnel Documents
Culture Documents
Object-oriented Analysis
COMP316 OOMISD 1
Overview
COMP316 OOMISD 2
Analysis: Extract These Three Types of
Classes
• Stereotypes (extensions of UML)
COMP316 OOMISD 3
The Analysis Workflow
• Entity class
– Models long-lived information
• leads to more stable design over time
• Examples:
– Account Class
– Investment Class
COMP316 OOMISD 4
The Analysis Workflow (contd)
• Boundary class
– Models the interaction between the product and the
environment
– A boundary class is generally associated with input or output
• Examples:
– Investments Report Class
– Mortgages Report Class
COMP316 OOMISD 5
The Analysis Workflow (contd)
• Control class
– Models complex computations and algorithms
– usually the hardest to identify
• Example:
– Estimate Funds for Week Class
COMP316 OOMISD 6
Extracting the Entity Classes
COMP316 OOMISD 7
The Elevator Problem
A product is to be installed to control n elevators in a building with m floors:
1. Each elevator has a set of m buttons, one for each floor.
1. These illuminate when pressed and cause the elevator to visit the
corresponding floor.
2. The illumination is canceled when the corresponding floor is visited by
the elevator
2. Each floor, except the first and the top floor, has two buttons,
1. one to request an up-elevator,
2. one to request a down-elevator.
3. These buttons illuminate when pressed.
4. The illumination is canceled when an elevator visits the floor, then moves
in the desired direction
3. If an elevator has no requests, it remains at its current floor with its doors
closed
COMP316 OOMISD 8
Functional Modelling: Use Cases
• For the elevator problem, there are two possible use cases
– Press an Elevator Button (inside elevator carriage), and
– Press a Floor Button (on each floor)
COMP316 OOMISD 9
Scenarios
COMP316 OOMISD 10
Normal Scenario: Elevator Problem
COMP316 OOMISD 11
Exception Scenario: Elevator Problem
COMP316 OOMISD 12
Entity Class Modeling : The Elevator Problem Case Study
• One alternative: Deduce the classes from use cases and their
scenarios
– Possible danger: Often there are many scenarios, and hence
– Too many candidate classes
• Other alternatives:
– CRC cards (if you have domain knowledge)
– Noun extraction
COMP316 OOMISD 13
First Iteration of Class Diagram
• Problem
– Buttons do not communicate directly with elevators
– We need an additional class: Elevator Controller Class
COMP316 OOMISD 14
Second Iteration of Class Diagram
• All relationships
are now 1-to-n
– This makes design
and
implementation
easier
COMP316 OOMISD 15
CRC Cards
• Used since 1989 for OOA
• For each class, fill in a card showing
– Name of Class
– Functionality (Responsibility)
– List of classes it invokes (Communication)
• Now CRC cards are automated (CASE tool component)
• Strength
– When acted out by team members, CRC cards are a powerful tool for
highlighting missing or incorrect items
• Weakness
– If CRC cards are used to identify entity classes, domain expertise is needed
COMP316 OOMISD 16
Dynamic Modeling: The Elevator Problem Case Study
• Produce a UML
statechart
• State, event,
and predicate
are distributed
over the
statechart
COMP316 OOMISD 17
The Test Workflow: Elevator Problem
• CRC cards are an
excellent testing
technique
COMP316 OOMISD 18
CRC Cards
• Consider responsibility
– 1.
Turn on elevator button
• Responsibility
1.
Turn on elevator button
should be
1.
Send message to Elevator Button Class to turn
itself on
COMP316 OOMISD 19
CRC Cards (contd)
COMP316 OOMISD 20
Second Iteration of the CRC Card
COMP316 OOMISD 21
CRC Cards (contd)
COMP316 OOMISD 22
Third Iteration of Class Diagram
COMP316 OOMISD 23
Second Iteration of the Normal Scenario:
COMP316 OOMISD 24
Extracting the Boundary and Control Classes
• Each
– Input screen,
– Output screen, and
– Report
is modeled by its own boundary class
COMP316 OOMISD 25
The Initial Functional Model: MSG Foundation
● Recall the seventh iteration of the use-case diagram
COMP316 OOMISD 26
Use Case Manage a Mortgage
COMP316 OOMISD 27
Use Case Manage a Mortgage (contd)
COMP316 OOMISD 28
Use Case Estimate Funds Available for Week
• One
possible
scenario
COMP316 OOMISD 29
Use Case Produce a Report
COMP316 OOMISD 30
Use Case Produce a Report (contd)
COMP316 OOMISD 31
Noun Extraction: MSG Foundation
COMP316 OOMISD 32
Noun Extraction: MSG Foundation
(contd)
• Stage 2: Identify the nouns in this paragraph
– Weekly reports are to be printed showing how much money is
available for mortgages. In addition, lists of investments and
mortgages must be printed on demand.
COMP316 OOMISD 33
Noun Extraction: MSG Foundation
(contd)
• Nouns report and list are not long-living, so they are
unlikely to be entity classes
– (report will turn out to be a boundary class)
COMP316 OOMISD 34
First Iteration of the Initial Class
Diagram
COMP316 OOMISD 35
Second Iteration of the Initial Class
Diagram
• Operations performed on the two entity classes are
likely to be very similar
– Insertions, deletions, and modifications
– All members of both entity classes have to be printed on
demand
COMP316 OOMISD 36
Second Iteration of Initial Class
Diagram (contd)
COMP316 OOMISD 37
Back to the Requirements Workflow
COMP316 OOMISD 38
Eighth Iteration of the Use-Case Diagram
• The new use case is shaded
COMP316 OOMISD 39
Initial Class Diagram: MSG Foundation
(contd)
• Finally, we add the attributes of each class to the
class diagram
– asset number, investment name, estimated annual return, last
name of mortgagor, ...
COMP316 OOMISD 40
Second Iteration of Initial Class
Diagram (contd)
COMP316 OOMISD 41
Initial Dynamic Model: MSG Foundation (contd)
COMP316 OOMISD 42
Initial Dynamic Model: MSG Foundation (contd)
COMP316 OOMISD 43
Initial Dynamic Model: MSG Foundation (contd)
COMP316 OOMISD 44
Revising the Entity Classes: MSG Foundation
• In the initial statechart, consider state Update Estimated
Annual Operating Expenses
– with operation Update the estimated annual operating expenses has to be
performed on the current value of the estimated annual operating
expense
• But where is the value of the estimated annual operating expenses
to be found?
– Currently there is only one class (Asset Class) and its two subclasses
– Neither is appropriate for storing the estimated annual operating
expenses. Why?
– The only way a value can be stored on a long-term basis is
• as an attribute of an instance of that class or its subclasses
• Another entity class is needed for storing the estimated annual
operating expenses
– MSG Application Class
COMP316 OOMISD 45
Third Iteration of the Initial Class Diagram: MSG Foundation
• MSG Application
Class has other
attributes as well
– Attributes that
do not belong to
the assets
COMP316 OOMISD 46
Third Iteration of the Initial Class Diagram: MSG Foundation
COMP316 OOMISD 47
Extracting the Boundary Classes: MSG Foundation
• One screen should be adequate for all four MSG Foundation use
cases
• Estimate Funds Available for Week
• Manage an Asset
• Update Estimated Annual Operating Expenses
• Produce a Report
COMP316 OOMISD 48
Extracting Boundary Classes: MSG Foundation (contd)
COMP316 OOMISD 49
Extracting Boundary Classes: MSG (contd)
COMP316 OOMISD 50
Initial Boundary Classes: MSG Foundation (contd)
COMP316 OOMISD 51
Extracting the Control Classes: MSG Foundation
COMP316 OOMISD 52
Use-Case Realization
COMP316 OOMISD 53
Estimate Funds Available for Week Use Case
COMP316 OOMISD 54
Estimate Funds Available for Week Use Case (contd)
COMP316 OOMISD 55
Estimate Funds Available for Week Use Case (contd)
class diagram -
does not show
sequence of
events.
COMP316 OOMISD 56
Estimate Funds Available for Week Use Case (contd)
• The six classes that enter into this use case are:
– User Interface Class
• This class models the user interface
– Estimate Funds for Week Class
• This control class models the computation of the estimate of the
funds that are available to fund mortgages during that week
– Mortgage Class
• This class models the estimated grants and payments for the week
– Investment Class
• This class models the estimated return on investments for the week
– MSG Application Class
• This class models the estimated operating expenses for the week
– Estimated Funds Report Class
• This class models the printing of the report
COMP316 OOMISD 57
Estimate Funds Available for Week Use Case (contd) -
COMP316 OOMISD 58
Estimate Funds Available for Week Use Case (contd)
COMP316 OOMISD 59
Estimate Funds Available for Week Use Case -
Communication Diagram (Collaboration Diagram)
COMP316 OOMISD 60
Estimate Funds Available for Week Use Case -
Sequence Diagram
COMP316 OOMISD 61
Interaction Diagrams
COMP316 OOMISD 62
Manage an Asset Use Case
COMP316 OOMISD 63
Manage an Asset Use Case (contd)
COMP316 OOMISD 64
Manage an Asset Use Case - Class Diagram
COMP316 OOMISD 65
Manage an Asset Use Case - one scenario
COMP316 OOMISD 66
Manage an Asset Use Case (contd) - Communication Diagram
COMP316 OOMISD 67
Manage an Asset Use Case (contd)
COMP316 OOMISD 68
Manage an Asset Use Case (contd) -
Sequence Diagram
COMP316 OOMISD 69
Manage an Asset Use Case (contd) - a different scenario
COMP316 OOMISD 70
Manage an Asset Use Case (contd) - Communication Diagram
COMP316 OOMISD 71
Manage an Asset Use Case (contd)
COMP316 OOMISD 72
Manage an Asset Use Case (contd) - Sequence Diagram
COMP316 OOMISD 73
Manage an Asset Use Case (contd)
COMP316 OOMISD 74
Manage an Asset Use Case (contd)
• Revised menu
COMP316 OOMISD 75
Manage an Asset Use Case (contd)
COMP316 OOMISD 76
Update Estimated Annual Operating Expenses Use Case -
Class Diagram
COMP316 OOMISD 77
Update Annual Operating Expenses Use Case
(contd) - Communication Diagram
COMP316 OOMISD 78
Update Annual Operating Expenses Use Case (contd) -
Sequence Diagram
COMP316 OOMISD 79
Produce a Report Use Case
COMP316 OOMISD 80
Produce a Report Use Case (contd)
COMP316 OOMISD 81
Produce a Report Use Case (contd) - Class Diagram
COMP316 OOMISD 82
Produce a Report Use Case (contd) - one scenario
COMP316 OOMISD 83
Produce a Report Use Case (contd) - Communication Diagram
– Mortgages
(but not
investments)
are involved
COMP316 OOMISD 84
Produce a Report Use Case (contd) - Sequence Diagram
COMP316 OOMISD 85
Produce a Report Use Case (contd) - a second scenario
COMP316 OOMISD 86
Produce a Report Use Case (contd) - Communication Diagram
COMP316 OOMISD 87
Produce a Report Use Case (contd) - Sequence Diagram for
Second Scenario
COMP316 OOMISD 88
Combining the Realization Class Diagrams
COMP316 OOMISD 89