Objectives: Use-Case Analysis Understand the purpose of Use-Case Analysis and where in the lifecycle it is performed Identify the classes which perform a use- case flow of events Di
Trang 1Object Oriented Analysis and Design
Using the UML
Module : Use-Case Analysis
Trang 2Objectives: Use-Case Analysis
Understand the purpose of Use-Case Analysis and where in
the lifecycle it is performed
Identify the classes which perform a use- case flow of
events
Distribute the use-case behavior to those classes, identifying
responsibilities of the classes
Develop use-case realizations that model the collaborations
between instances of the identified classes
Trang 3Use-Case Analysis in Context
Designer Use-Case
Analysis
Trang 4Use-Case Analysis in Context
we have made an initial attempt at defining our
architecture we have defined the upper layers of our architecture, the key abstractions, and some key analysis mechanisms This initial architecture, along with the software requirements defined in the
Requirements workflow, guides and serves as input
to the Use-Case Analysis activity.
In Use-Case Analysis, we identify the analysis classes
and define their responsibilities As the analysis
classes and their responsibilities are defined, we will also note the usage of any architectural (more
specifically, analysis) patterns defined in
Architectural Analysis The architectural layers and their dependencies may affect the allocation of
responsibility to the defined analysis classes.
Trang 5Use-Case Modeling Guidelines
Analysis Model (optional)
Use-Case Analysis Overview
Software Architecture
Document
Trang 6Requirement Capture and Analysis –Conceptual Model
Conceptual Model – Concepts and Classes
Important and typical activity in object-oriented requirement
analysis is to identify concepts related to the requirements and to create a conceptual model of the domain
Conceptual Model or domain model
illustrates meaningful (to the modelers) conceptual classes in a
problem domain
A domain model OR conceptual models is a visual
representation of conceptual classes or real-world objects in
a domain of interest
Trang 7Requirement Capture and Analysis –Conceptual Model (Cont.)
The aim of this step is to decompose the problem in terms of
individual concepts or objects
A central distinction between OOA and structured analysis is
decomposition by concepts (objects) rather than decomposition by functions
Trang 8Requirement Capture and Analysis –Conceptual Model (Cont.)
Problem word
modeling
Concept model
Trang 9Requirement Capture and Analysis –Conceptual Model (Cont.)
Conceptual Models Are not Models of Software Components
they models Conceptual Classes
The conceptual modeling process is fundamentally an
inside-out approach Inside-out means that we’re starting with the core objects in the system, then working from the inside outward, to see how those objects are going to
participate in the system we’re building
Trang 10Use-Case Analysis Steps
Supplement the Use-Case Description
For each use-case realization
Find Classes from Use-Case Behavior
Distribute Use-Case Behavior to Classes
For each resulting analysis class
Describe Responsibilities
Describe Attributes and Associations
Qualify Analysis Mechanisms
Unify Analysis Classes
Checkpoints
Trang 11Use-Case Analysis Steps
Supplement the Use-Case Description
For each use-case realization
Find Classes from Use-Case Behavior
Distribute Use-Case Behavior to Classes
For each resulting analysis class
Describe Responsibilities
Describe Attributes and Associations
Qualify Analysis Mechanisms
Unify Analysis Classes
Checkpoints
Trang 12• The system displays a list of
course
• The system retrieves and displays a list of current course offerings from the course catalog
Supplement the Use-Case Description
Trang 13 Supplement the Use-Case Description
For each use-case realization
Find Classes from Use-Case Behavior
Distribute Use-Case Behavior to Classes
For each resulting analysis class
Describe Responsibilities
Describe Attributes and Associations
Qualify Analysis Mechanisms
Unify Analysis Classes
Checkpoints
Use-Case Analysis Steps
Trang 14Professor name professorID: UniqueId create( )
save( ) delete( )
Class Name Attributes Operations
Trang 15Class Diagrams
Sequence Diagrams
Use Case
Collaboration Diagrams
Review: Use-Case Realization
Trang 16Find Classes From Use-Case Behavior
The complete behavior of a use case has to be distributed to
analysis classes
Trang 17System boundary
Use-case behavior coordination
System information
What is an Analysis Class?
<<boundary>>
<<control>>
<<entity>>
Trang 18Use Cases Analysis
Classes
Source Code
Exec
Design Elements
Analysis Classes: A First Step Towards Executables
Trang 19Environment Dependent
Analysis class stereotype
What is a Boundary Class?
Intermediates between the interface and something outside
the system
Several Types
User interface classes
System interface classes
Device interface classes
One boundary class per actor/use case pair
Trang 20Model interaction between the system and its environment
Trang 21Course Catalog System Register for Courses
Student
Example: Finding Boundary Classes
One boundary class per actor/use case pair
RegisterForCoursesForm CourseCatalogSystem
Trang 22Concentrate on the responsibilities, not the details!
Guidelines: Boundary Class
User Interface Classes
Concentrate on what information is presented to the user
Do NOT concentrate on the UI details
System and Device Interface Classes
Concentrate on what protocols must be defined
Do NOT concentrate on how the protocols will be implemented
Trang 23Business-Domain Model
Environment Independent
Analysis class stereotype
Use Case
Architectural Analysis
Abstractions
What is an Entity Class?
Key abstractions of the system
Trang 24Store and manage information in the system
Trang 25Example: Finding Entity Classes
Use use-case flow of events as input
Key abstractions of the use case
Traditional, filtering nouns approach
Underline noun clauses in the use-case flow of events
Remove redundant candidates
Remove vague candidates
Remove actors (out of scope)
Remove implementation constructs
Remove attributes (save for later)
Remove operations
Trang 26Example: Candidate Entity Classes
Register for Courses (Create Schedule)
Schedule CourseOffering
Student
Trang 27Use Case
Use-case dependent, Environment independent
Analysis class stereotype
What is a Control Class?
Use-case behavior coordinator
One control class per use case
Trang 28The Role of a Control Class
Coordinate the use-case behavior
Trang 29Course Catalog System Register for Courses
Student
Example: Finding Control Classes
One control class per use case
RegistrationController
Trang 30Student Register for Courses Course Catalog System
Use-Case Model
Design Model
Example: Summary: Analysis Classes
CourseCatalogSystem StudentRegisterForCoursesForm Schedule
Trang 31 Supplement the Use-Case Descriptions
For each use-case realization
Find Classes from Use-Case Behavior
Distribute Use-Case Behavior to Classes
For each resulting analysis class
Describe Responsibilities
Describe Attributes and Associations
Qualify Analysis Mechanisms
Unify Analysis Classes
Checkpoints
Use-Case Analysis Steps
Trang 32Sequence Diagrams Collaboration Diagrams
Distribute Use-Case Behavior to Classes
For each use-case flow of events:
Identify analysis classes
Allocate use-case responsibilities to analysis classes
Model analysis class interactions in interaction diagrams
Trang 33 Responsibilities are related to the obligations of an object in
terms of its behavior
Two types of responsibilities :
•doing something itself, such as
creating an object or doing a
calculation
•initiating action in other objects
•controlling and coordinating
activities in other objects
knowing about private
encapsulated data
knowing about related objects
knowing about things it can derive
or calculate
Trang 34 Responsibilities are assigned to classes of objects during object
design:
a Sale is responsible for creating SalesLineltem
a Sale is responsible for knowing its total
A responsibility is not the same thing as a method, but methods
are implemented to fulfill responsibilities:
the responsibility to “calculate a Sale" may involve only one or few methods
Assigning responsibilities to software classes is very important:
Easier to understand, maintain, extend and reuse
Trang 35Guidelines: Allocating Responsibilities to Classes
Use analysis class stereotypes as a guide
Trang 36Guidelines: Allocating Responsibilities to Classes (cont.)
Who has the data needed to perform the responsibility?
One class has the data, put the responsibility with the data
Multiple classes have the data:
• Put the responsibility with one class and add a relationship to the other
• Create a new class, put the responsibility in the new class, and add relationships to classes needed to perform the responsibility
• Put the responsibility in the control class, and add relationships to classes needed to perform the responsibility
Trang 371.1: PerformAnother Responsibility
The Anatomy of Sequence Diagrams
Hierarchical Message
Numbering
Trang 38Sequence Diagrams
Sequence diagram is an interaction diagram that
emphasizes the time-ordering of messages in an interaction
Messages passed between objects manifest the interaction
Sequence diagram components
Objects
Lifelines
Messages
Iteration
Trang 39Sequence Diagrams
Elements
Objects - objects that participate in the interaction
shown as a box labeled at the top of a dashed vertical
(Object Name)!: Class-Name
Object lifelines - the lifetime of the object
represents the period of time during which the object exists
shown as vertical dashed lines from object boxes
Activations - Focus of control
represents the period of time during which an object is active (executing or waiting for a subroutine).
shown as a thin rectangle on an object’s lifeline.
Messages - communication between objects
shown with horizontal solid arrows between object lifelines; messages may be labeled.
message sequence is usually implicit in location of message arrows.
Trang 40Example: Sequence Diagram
A list of the available
course offerings for this
semester are displayed
Student wishes to
create a new
schedule
1 // create schedule( )
5 // display course offerings( )
2 // get course offerings( )
3 // get course offerings(forSemester)
6 // display blank schedule( )
7 // select 4 primary and 2 alternate offerings( )
8 // create schedule with offerings( )
9 // create with offerings( )
Trang 42Example: Collaboration Diagram
: Student
: RegisterForCoursesForm
: RegistrationController
: Schedule : Student
2 // select 4 primary and 2 alternate offerings( )
1.1 // get course offerings( ) 2.1 // create schedule with offerings( )
2.1.1 // create with offerings( )
1.1.1 // get course offerings(forSemester)
2.1.2 // add schedule(Schedule)
1.1.1.1 // get course offerings( )
Trang 43Example: Collaboration Diagram (cont.)
: CourseOffering
: Student
: RegistrationController
: Schedule
: Student
: PrimaryScheduleOfferingInfob
1.1.2.2 // has pre-requisites(CourseOffering)
Trang 44Alternate Flow 4 Alternate Flow 5 Alternate Flow n
AF1 AF2 AF3
Basic Flow
One Interaction Diagram Is Not Good Enough
Trang 45Collaboration Diagrams Vs Sequence Diagrams
Trang 46 Supplement the Use-Case Descriptions
For each use-case realization
Find Classes from Use-Case Behavior
Distribute Use-Case Behavior to Classes
For each resulting analysis class
Describe Responsibilities
Describe Attributes and Associations
Qualify Analysis Mechanisms
Unify Analysis Classes
Checkpoints
Use-Case Analysis Steps
Trang 47// PerformResponsibility
Supplier // PerformResponsibility
Interaction Diagram
Class Diagram
Describe Responsibilities
What are responsibilities?
How do I find them?
Trang 48// select 4 primary and 2 alternate offerings()
// display blank schedule()
<<boundary>>
PrimaryScheduleOfferingInfo grade
// is enrolled in?() // mark as enrolled in()
<<entity>>
CourseCatalogSystem // get course offerings()
<<boundary>>
RegistrationController
// get course offerings() // submit schedule() // create schedule with offerings()
<<control>>
Student
// add schedule() // has pre-requisites()
<<entity>>
ScheduleOfferingInfo status
// mark as selected() // mark as cancelled() // is selected?()
<<entity>>
CourseOffering number : String = "100"
startTime : Time endTime : Time days : Enum // add student()
Trang 49Maintaining Consistency: What to Look For
In order of criticality
Redundant responsibilities across classes
Disjoint responsibilities within classes
Class with one responsibility
Class with no responsibilities
Better distribution of behavior
Class that interacts with many other classes
Trang 50 Supplement the Use-Case Descriptions
For each use-case realization
Find Classes from Use-Case Behavior
Distribute Use-Case Behavior to Classes
For each resulting analysis class
Describe Responsibilities
Describe Attributes and Associations
Qualify Analysis Mechanisms
Unify Analysis Classes
Checkpoints
Use-Case Analysis Steps
Trang 51Attribute : Type = InitValue Attribute : Type = InitValue Attribute : Type = InitValue
CourseOffering<<entity>>
number :String=“100”
startTime : Time endTime: Time days: enum
Trang 52Finding Attributes
Properties/characteristics of identified classes
Information retained by identified classes
“Nouns” that did not become classes
Information whose value is the important thing
Information that is uniquely "owned” by an object
Information that has no behavior
Trang 53Review: What is an Association?
The semantic relationship between two or more classifiers
that specifies connections among their instances
A structural relationship, specifying that objects of one thing
are connected to objects of another
Simple association
is a pre-requisite of
<<entity>> Course
Trang 55Whole/aggregate part
0 4 0 2
primaryCourses alternateCourses
Review: What is Aggregation?
A special form of association that models a whole-part
relationship between an aggregate (the whole) and its parts
Trang 56 The relationship is an aggregation
If two objects are usually considered as
independent, although they are often linked
The relationship is an association
When in doubt use association
Trang 57What are Roles?
The “face” that a class plays in the association
Trang 58Review: Multiplicity
2 4 0 1 1 *
0 * 1
Trang 59What does multiplicity mean?
Multiplicity answers two questions:
Is the association mandatory or optional?
What is the minimum and maximum number of instances that can be linked to one instance?
Trang 60<<entity>> add student to
remove student from
Example: Multiple Associations
Trang 611 0 *
1 1
Schedule // create with offerings()
<<entity>>
1 0 1
RegisterForCoursesForm // create schedule ()
// display course offerings () // display blank schedule // select 4 primary and 2 alternate offerings()
<<entity>>
currentSchedule registrant
0 1 0 1
Example: VOPC: Finding Relationships
Trang 62 Supplement the Use-Case Descriptions
For each use-case realization
Find Classes from Use-Case Behavior
Distribute Use-Case Behavior to Classes
For each resulting analysis class
Describe Responsibilities
Describe Attributes and Associations
Qualify Analysis Mechanisms
Unify Analysis Classes
Checkpoints
Use-Case Analysis Steps