Identifying Use Cases - Object Analysis - Classification
Identifying Use Cases - Object Analysis - Classification
Identifying Use Cases - Object Analysis - Classification
O-O Analysis
Developing Business Processes
• Developing an activity diagram of the
business processes can provide us with
an overall view of the system.
Use Case Model
• Use cases are scenarios for understanding
system requirements.
• The use-case model describes the uses of
the system and shows the courses of events
that can be performed.
• Some Definitions
– User – Human Users + Other Systems
– Use Case – A piece of functionality
– Use-Case Model – All the use cases
– Use-Case Driven – Development
process follows a flow
Use case Driven
Product development is Use case driven:
• Capture the user’s needs (requirements - in users context)
- Helps in Project Scheduling
• Analyse to specify the needs
• Design to realize the needs
• Implement to implement the needs
• Test to verify the needs Verified by
Te s t1 Te s t3
Implemented by Tes t2
Realized by
Use cases Test
Specified by Design1
Design2
Design4
Design3
Implementation
Design
Analysis
Use Case Model (Con’t)
B o rro w b o o k s u ses
C h e c k in g L ib ra ry C a rd
e x te n d s
uses
In te r lib ra ry lo a n
C irc u la tio n C le rk
M em ber R e tu rn B o o k s
P e rfo rm in g re s e a rc h
R e a d in g b o o k s S u p p lie r
N ew spaper
P u rc h a s in g S u p p lie s
Fully Developed
Use Case Description
Use Case Name: Checkout Movies
Scenario: Checkout movies at counter
Triggering Event: Customer brings movies to checkout counter
Brief Description: When customer brings movies to counter, clerk checks membership ID,
clerk scans in each movie identifier, takes payment, and notifies
customer of return due date and time.
Actors: Video clerk
Related Use Cases: Add new member
Association
Use Case
<<Uses>>
<<Extends>>
Types of Use Cases
• Use cases could be viewed as concrete
or abstract.
• An abstract use case is not complete
and has no initiation actors but is used
by a concrete use case, which does
interact with actors.
Identifying the Actors
• The term actor represents the role a
user plays with respect to the system.
• When dealing with actors, it is important
to think about roles rather than
people or job titles.
Identifying the Actors (Con’t)
• Candidates for actors can be found
through the answers to the following
questions:
– Who is using the system? Or,
– Who is affected by the system? Or,
– Which groups need help from the system
to perform a task?
Identifying the Actors (Con’t)
– Who affects the system? Or,
– Which user groups are needed by the
system to perform its functions? These
functions can be both main functions and
secondary functions, such as
administration.
– Which external hardware or other systems
(if any) use the system to perform tasks?
Identifying the Actors (Con’t)
– What problems does this application solve
(that is, for whom)?
– And, finally, how do users use the system
(use case)? What are they doing with the
system?
Guidelines for Finding Use
Cases
• For each actor, find the tasks and
functions that the actor should be able
to perform or that the system needs the
actor to perform.
• Name the use cases.
• Describe the use cases briefly by
applying terms with which the user is
familiar.
Separate Actors From Users
• Each use case should have only one
main actor.
• Isolate users from actors.
• Isolate actors from other actors
(separate the responsibilities of each
actor).
• Isolate use cases that have different
initiating actors and slightly different
behavior.
Documentation
• An effective document can serve as a
communication vehicle among the
project's team members, or it can serve
as initial understanding of the
requirements.
Effective Documentation:
Common Cover
• All documents should share a common
cover sheet that identifies the
document, the current version, and the
individual responsible for the content.
80–20 Rule
• 80 percent of the work can be done with 20
percent of the documentation.
• The trick is to make sure that the 20 percent
is easily accessible and the rest (80
percent) is available to those (few) who
need to know.
80%-
Familiar Vocabulary
• Use a vocabulary that your readers
understand and are comfortable with.
• The main objective here is to
communicate with readers and not
impress them with buzz words.
Make the Document as Short as
Possible
• Eliminate all repetition;
• Present summaries, reviews, organization
chapters in less than three pages;
• Make chapter headings task
oriented so that the table of
contents also could serve as
an index.
Organize the Document
• Use the rules of good organization
(such as the organization's standards,
college handbooks, Strunk and White's
Elements of Style, or the University of
Chicago Manual of Style) within each
section.
Summary
• The main objective of the analysis is to
capture a complete, unambiguous, and
consistent picture of the requirements
of the system.
• Construct several models and views of
the system to describe what the
system does rather than how.
Summary (Con’t)
• Capturing use cases is one of the first
things to do in coming up with
requirements.
• Every use case is a potential requirement.
Summary (Con’t)
• The key in developing effective
documentation is to eliminate all
repetition; present summaries, reviews,
organization chapters in less than three
pages.
• Use the 80–20 rule: 80 percent of the
work can be done with 20 percent of the
documentation.
Object Analysis: Classification
Introduction
• OOA is a process by which we can identify
classes that play a role in achieving system
goals and requirements
• Various Approaches for identifying the classes
• Classification: is the process of checking to see
if an object belongs to a category or a class, is
regarded as a basic attribute of human nature.
Example: Classifying the car
What is an Object
– An object Is an unique, identifiable, self-
contained entity that possesses operations
and contains attributes
– • Possesses all the know-how and information
it needs to perform the services for which it
was designed
– Is a "black box" which receives and sends
messages
What is a Class ?
• A Class is a software template that defines
the methods and variables to be included in a
particular kind of Object.
• Is a blue print used to create objects. As it is a
blue print, at runtime it will not occupy any
memory.
• Examples :
Animal, Human being, Automobiles
Classes VS. Objects
Class Object
Class
Synchronous
message
Asynchronous
message
Focus of Control
Return message
Termination
lifeline
C lie n t A T M M a c h in eB a n k C lie n t
I n s e r t A T M c a r d
R e q u e s t P I N
R e q u e s t P I N n u m b e r
V e r if y P I N N u m b e r
B a d P I N N u m b e r
B a d P I N N u m b e r
M e s s a g e
E je c t A T M c a r d
R e q u e s t t a k e c a r d
T a k e c a r d
D is p la y m a in s c r e e n
B a n k C l i e A n Tt M M a c h Ai n c e c o u n t C h e c k i n g A c c o u n t
R e q u e s t K i n d
E n t e r K in d
R e q u e s t A m o u n t
E n t e r A m o u n t
P r o c e s s T r a n s a c t io n
W it h d r a w C h e c k in g A c c o u n t
T r a n s a c t io n sW u ci t ch ed er a d w S u c c e s s f u l
D is p e n s e C a s h
R e q u e s t T a k e C a s h
T a k e C a s h
R e q u e s t C o n t in u a t io n
T e r m in a t e
P r in t R e c e ip t
2 : E n te r K in d
5 : P ro c e s s T ra n s a c tio n
4 : E n te r A m o u n t
1 3 : T e r m in a te
A ccount A T M M a c h in e : D e f in it io n B a n k C lie n t
8 : T r a n s a c t io n s u c c e e d
1 : R e q u e s t K in d
3: R equest A m ount
9 : D is p e n s e C a s h
10: R equest Take C ash
7 : W it h d r a w S u c c e s s f u l 6 : W ith d ra w C h e c k in g A c c o u n t
11: Take C ash
1 2 : R e q u e s t C o n t in u a t io n
C h e c k in g A c c o u n t 1 4 : P r in t R e c e ip t
COLLABORATION DIAGRAM
• A Collaboration is a name given to the
interaction among two or more
classes\objects.
• Collaboration Diagram show
– objects and their links to each other, as well as
– how messages are sent between the linked
objects.
COLLABORATION DIAGRAM CONT.,
• Collaboration shows
– the implementation of an operation or
– the realization of a use case.
• The focus here is on Message.(Hence
numbered)
• 5o focus on message means that they focus
on object roles instead of time, and therefore
explicitly shown in the diagram.
COLLABORATION DIAGRAM
COLLABORATION DIAGRAM -
PURPOSE
Identify
Classes
responsibility
Iterate
Identify Assign
Collaboration responsibility
Collaborations
• An object can accomplish either a
certain responsibility itself, or it may
require the assistance of other objects.
• If it requires an assistance of other
objects, it must collaborate with
those objects to fulfill
its responsibility.
CRC Cards (Con’t)
• CRC cards are 4" x 6" index cards. All
the information for an object is written
on a card.
ClassName
...
Collaborators
...
Responsibilities
CRC Cards (Con’t)
• CRC starts with only one or two obvious
cards.
• If the situation calls for a responsibility not
already covered by one of the objects:
– Add, or
– Create a new object to address that
responsibility.
Guidelines for Naming Classes
• The class should describe a single
object, so it should be the singular form
of noun.
• Use names that the users are
comfortable with.
• The name of a class should reflect its
intrinsic nature.
Guidelines for Naming Classes
(Con’t)
• By the convention, the class name must
begin with an upper case letter.
• For compound words, capitalize the first
letter of each word - for example,
LoanWindow.
Summary
• Finding classes is not easy.
• The more practice you have, the better
you get at identifying classes.
• There is no such thing as the “right set
of classes.”
• Finding classes is an incremental
and iterative process.
Summary (Con’t)
• Unless you are starting with a lot of
domain knowledge, you are probably
missing more classes than you will
eliminate.
• Naming a class is also an important
activity.
• The class should describe a single
object, so it should be a singular noun
or an adjective and a noun.
Identifying Object
Relationships, Attributes, and
Methods
Goals
C u s t o m e r O p e r a t o r
O r d e r
Eliminate Unnecessary
Associations
• Implementation association. Defer
implementation-specific associations to the
design phase.
• Ternary associations. Ternary or n-ary
association is an association among more
than two classes
Eliminate Unnecessary
Associations (Con’t)
• Directed actions (derived) associations
can be defined in terms of other
associations.
• Since they are redundant you should
avoid these types of association.
Eliminate Unnecessary
Associations (Con’t)
• Grandparent of Ken can be
defined in terms of the
parent association.
G r a n d P a r e n t
J o h n o f K e n
P a r e n t P a r e n t
J o h n
o f B r i a n o f
K e n
Superclass-Subclass
Relationships
• Recall that at the top of the class hierarchy
is the most general class, and from it
descend all other, more specialized
classes.
• Sub-classes are more specialized
versions of their super-classes.
Guidelines For Identifying
Super-sub Relationships: Top-
down
• Look for noun phrases composed of
various adjectives on class name.
• Example, Military Aircraft and Civilian
Aircraft.
• Only specialize when the sub
classes have significant behavior.
Guidelines For Identifying
Super-sub Relationships:
Bottom-up
• Look for classes with similar attributes or
methods.
• Group them by moving the common
attributes and methods to super class.
• Do not force classes to fit a preconceived
generalization structure.
Guidelines For Identifying
Super-sub Relationships:
Reusability
• Move attributes and methods as high as
possible in the hierarchy.
• At the same time do not create very
specialized classes at the top of hierarchy.
• This balancing act can be
achieved through several
iterations.
Guidelines For Identifying
Super-sub Relationships:
Multiple inheritance
• Avoid excessive use of multiple
inheritance.
• It is also more difficult to understand
programs written in multiple
inheritance system.
Multiple inheritance (Con’t)
• One way to achieve the benefits of multiple
inheritance is to inherit from the most
appropriate class and add an object of other
class as an attribute.
• In essence, a multiple inheritance can be
represented as an aggregation
of a single inheritance and
aggregation. This meta
Multiple Inheritance
C a rb u re to r
A-Part-of Relationship -
Aggregation (Con’t)
• Two major properties of a-part-of
relationship are:
– transitivity
– antisymmetry
Transitivity
• If A is part of B and B is part of C, then A
is part of C.
• For example, a carburetor is part of an
engine and an engine is part of a car;
therefore, a carburetor is part of a car.
Antisymmetry
• If A is part of B, then B is not part of A.
• For example, an engine is part of a car,
but a car is not part of an engine.
Where responsibilities for
certain behavior must reside?
• Does the part class belong to problem
domain?
• Is the part class within the system's
responsibilities?
where responsibilities ...(Con’t)
• Does the part class capture more than
a single value?
• If it captures only a single value, then
simply include it as an attribute with the
whole class.
• Does it provide a useful abstraction in
dealing with the problem domain?
A-Part-of Relationship Patterns
Assembly
• An assembly-Part situation physically
exists.
• For example, a French soup consists of
onion, butter, flour, wine, French bread,
cheddar cheese, etc.
A-Part-of Relationship
Patterns
Container
• A case such as course-teacher situation,
where a course is considered as a
container. Teachers are assigned to
specific courses.
A-Part-of Relationship Patterns
Collection-Member
• A soccer team is a collection of players.
F o o t b a ll T e a m
P la y e r
Class Responsibility:
Identifying Attributes and
Methods
• Identifying attributes and methods, like
finding classes, is a difficult activity.
• The use cases and other UML diagrams
will be our guide for identifying attributes,
methods, and relationships among
classes.
Identifying Class Responsibility
by Analyzing Use Cases and
Other UML Diagrams
• Attributes can be identified by
analyzing the use cases,
sequence/collaboration, activity, and
state diagrams.
Responsibility
• How am I going to be used?
• How am I going to collaborate with
other classes?
• How am I described in the context of
this system's responsibility?
• What do I need to know?
• What state information do I need to
remember over time?
• What states can I be in?
Assign Each Responsibility To
A Class
• Assign each responsibility to the class
that it logically belongs to.
• This also aids us in determining the
purpose and the role that each class
plays in the application.
Object Responsibility: Attributes
• Information that the system needs to
remember.
Guidelines For Identifying
Attributes Of Classes
• Attributes usually correspond to nouns
followed by possessive phrases such as
cost of the soup.
Guidelines For Identifying
Attributes Of Classes (Con’t)
• Keep the class simple; only state enough
attributes to define the object state.
Guidelines For Identifying
Attributes Of Classes (Con’t)
• Attributes are less likely to be fully
described in the problem statement.
• You must draw on your
knowledge of the application
R e q u e s t K in d
E n te r K in d
R equest Am ount
E n te r A m o u n t
P r o c e s s T r a n s a c t io n
W i t h d r a w C h e c k in g A c c o u n t
T r a n s a c t io n s u c c e e d W it h d r a w S u c c e s s f u l
D is p e n s e C a s h