Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Module6 - First Half

Download as pdf or txt
Download as pdf or txt
You are on page 1of 128

MODULE 6

OBJECT ORIENTED ANALYSIS


FACULTY HANDLED: PROF.KRITHIKA L B
TOPICS
Identifying use cases
Object Analysis

Classification

Identifying Object relationships

Attributes and Methods.


OBJECT ORIENTED
ANALYSIS PROCESS:
IDENTIFYING USE CASES
IDENTIFYING THE USE CASES:
GOALS
The use-case approach to object-oriented analysis
and the object-oriented analysis process.
Identifying actors.

Identifying use cases.

Documentation.
WHAT IS ANALYSIS?

Analysis is the process of transforming a problem


definition from a fuzzy set of facts and myths into a
coherent statement of a systems requirements.
The main objective of the analysis is to capture:
a complete, unambiguous, and consistent picture of the
requirements of the system and
what the system must do to satisfy the users'
requirements and needs.
WHERE SHOULD WE START?

1. Examination of existing system documentation.


2. Interviews.

3. Questionnaire.

4. Observation.
REQUIREMENTS DIFFICULTIES

Three most common sources of requirements


difficulties are:
1. Incomplete requirements.
2. Fuzzy descriptions (such as fast response).
3. Unneeded features.
THE OBJECT-ORIENTED ANALYSIS (OOA) PROCESS

The process consists of the following steps:


1. Identify the actors:
Who is using the system?
Or, in the case of a new system, who will be using
system?
THE OOA PROCESS (CONT)
2. Develop a simple business process model using
UML activity diagram.
THE OOA PROCESS (CONT)
3. Develop the use case:
What the users are doing with the system?
Or, in the case of a new system, what users will be
doing with the system?

Use cases provide us with comprehensive


documentation of the system under study.
THE OOA PROCESS (CONT)

4. Prepare interaction diagrams:


Determine the sequence.
Develop collaboration diagrams.
THE OOA PROCESS (CONT)
5. Classificationdevelop a static UML class
diagram:
Identify classes.
Identify relationships.
Identify attributes.
Identify methods.
THE OOA PROCESS (CONT)
6. Iterate and refine: If needed, repeat the
preceding steps.

Develop Use- Develop Identify Classes,


Cases, ADs Refine
Interaction Relationships, and
Diagrams Attributes & iterate
Identify Actors prototyping Methods

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 users 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
Test1 Test3

Implemented by Test2

Realized by
Use cases Test
Specified by Design1

Design2

Design4

Design3
Implementation

Design
Analysis
USE CASE MODEL (CONT)

Use case defines what happens in the system when


a use case is performed.
The use-case model tries to systematically identify
uses of the system and therefore the system's
responsibilities.
USE CASES UNDER THE MICROSCOPE
"A Use Case is a sequence of transactions in a
system whose task is to yield results of measurable
value to an individual actor of the system."
USE CASE KEY CONCEPTS
Use case. Use case is a special flow of events
through the system.
Actors. An actor is a user playing a role with
respect to the system.
In a system. This simply means that the actors
communicate with the system's use case.
USE CASE KEY CONCEPTS (CONT)

A measurable value. A use case must help the actor


to perform a task that has some identifiable value.
Transaction. A transaction is an atomic set of
activities that are performed either fully or not at
all.
USE ASSOCIATIONS(INCLUDES)

The use association occurs when you are describing


your use cases and notice that some of them have
common subflows.
The use association allows you to extract the
common subflow and make it a use case of its own.
EXTENDS ASSOCIATIONS

The extends association is used when you have one


use case that is similar to another use case but does
a bit more or
Is more specialized; in essence, it is like a subclass.
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 Add new member
Cases:
Stakeholders: Clerk, Store manager
Preconditions: Movie titles must exist
Movie copy must exist
Customer must exist (or Add new member must be invoked)
Postconditions: Video Rental and rental line items must be created
Payment transaction must be created
Status of movie copy must be updated
Video Rental must be connected to customer family member
USE CASE DIAGRAM NOTATION
Actor

Association

Use Case

Use case with Extension points

<<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.
Concrete words(noun) help us describe things eg:
shout; abstract words(qualities) help us classify
them. eg.truth
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.
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 (CONT)

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?
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.
All documents should share a common cover sheet
that identifies the document, the current version,
and the individual responsible for the content.
8020 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%-20%
FAMILIAR VOCABULARY

Use a vocabulary that your readers understand and


are comfortable with.
The main objective here is to communicate with
readers.
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.
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.
Capturing use cases is one of the first things to do
in coming up with requirements.
Every use case is a potential requirement.
SUMMARY (CONT)

The key in developing effective documentation is to


eliminate all repetition; present summaries,
reviews, organization chapters in less than three
pages.
Use the 8020 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
CONTD
Classification -the categorization of input data
(things) into identifiable classes through the
extraction of significant features of attributes of the
data from a background of irrelevant detail.
The main role of a class is to define the attributes,
methods and applicability of its instances
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
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.
Examples :
Animal, Human being, Automobiles
CLASSES VS. OBJECTS
Class Object

Class is a type/ template Object is an instance of


for similar objects the class

Class is purely a static Objects are run time /


concept, represented by dynamic entities that
program text occupy space in memory
POINT TO REMEMBER
Two Issues
A class is a specification of structure, behavior, and
the description of an object.
Classification is more concerned with identifying
classes than identifying the individual objects in a
system.
Employer Employee

Pet Owner Good Credit Risk


APPROACHES FOR IDENTIFYING CLASSES
The noun phrase approach.
The common class patterns approach.

The use-case driven approach.

The class responsibilities collaboration (CRC)


approach.
APPROACH1:NOUN PHRASE APPROACH
Object-oriented analysis is a process by which we
can identify classes that play a role in achieving
system goals and requirements.
Discovering classes is one of the hardest activities in

object-oriented analysis.

Aim of this approach:


You should be able to identify classes and verbs
NOUN PHRASE APPROACH
The noun phrase approach was proposed by Rebecca Wirfs-Brock,
Brian Wilkerson, and Lauren Wiener .
In this method, you read through the requirements or
use cases looking for noun phrases.
Nouns in the textual description are considered to be classes and
verbs to be methods of the classes .
All plurals are changed to singular, the nouns are listed, and the
list divided into three categories :
1.relevant classes
2.fuzzy classes (the "fuzzy area," classes we are
not sure about)
3.irrelevant classes(It is safe to scrap the irrelevant classes,
which either have no purpose or will be
unnecessary.)
NOUN PHRASE STRATEGY (CONT)
Change all plurals to singular and make a list,
which can then be divided into three categories.
KEEP IN MIND
Keep in mind that identifying classes and developing
a UML class diagram just like other activities is an
iterative process.
Depending on whether such object modelling

is for the analysis or design phase of development,


some classes may need to be added or removed from
the model .
You must be able to formulate a statement of
purpose for each candidate class; if not, simply
eliminate it.
Note: Candidate classes (an initial list of classes from
which the actual design classes will emerge) then are
selected from the other two categories.
GUIDELINES FOR IDENTIFYING CLASSES
The followings are guidelines for selecting classes in
your application:
Look for nouns and noun phrases in the problem
statement.
All classes must make sense in the application domain.

Carefully choose and define class names.

Note:
The more practice you have, the better you get at
identifying classes. Finding classes is an incremental
and iterative process.
GUIDELINES FOR REFINING CLASSES

(a)Redundant Classes:
Do not keep two classes that express the same
information.
If more than one word is being used to describe the
same idea, select the one that is the most meaningful
in the context of the system.
Note:
This is part of building a common vocabulary for the
system as a whole . Choose your vocabulary carefully;
use the word that is being used by the user of the
system.
GUIDELINES FOR REFINING CLASSES (CONT)
(b)Adjective Classes:
Does the object represented by the noun behave
differently when the adjective is applied to it?
eg.
Basketball coach here the noun basketball is being used
to describe the noun coach
A cricket bat
Accounts manager
Famous Indian cricket player
Note:
Beware of the use of adjectives. Adjectives can be used in many
ways. An adjective can suggest a different kind of object, different
use of the same object, or it could be utterly irrelevant.
GUIDELINES FOR REFINING CLASSES
(CONT)
If the use of the adjective signals that the
behavior of the object is different, then make a
new class.
For example, If Adult Membership and Youth
Membership behave differently, then they should
be classified as different classes.

Note:
Adult Members behave differently than Youth
Members, so ,the two should be classified as
different classes.
GUIDELINES FOR REFINING CLASSES
(CONT)
(c)Attribute Classes:
Tentative objects which are used only as values
should be defined or restated as attributes and not
as a class.
Eg:
Client Status and Demographic of Client are not
classes but attributes of the Client class
GUIDELINES FOR REFINING CLASSES
(CONT)
(d)Irrelevant Classes:
Each class must have a purpose and every class
should be clearly defined and necessary.
You must formulate a statement of purpose for
each candidate class.
If you cannot come up with a statement of purpose,
simply eliminate the candidate class.
NOTE
You can move back and forth among these steps as often as you like since this is an
incremental process.
Like any other activity of software development, the process of identifying relevant
classes and eliminating irrelevant classes is an incremental process.
The repetition of the entire process combined with what you already have learned
and the reworking of your candidate classes will enable you to gain a better
understanding of the system and the classes that make up your application.
Classification is the essence of good object-oriented analysis and design. You must
continue this refining cycle through the development process until you are satisfied
with the results.
You can move back and forth among these steps as often as you like (see next slide)
IDENTIFYING A LIST OF CANDIDATE
CLASSES

Take a coherent, concise statement of the


requirement of the system
Underline its noun and noun phrases, that is,
identify the words and phases the denote
things
This gives a list of candidate classes, which we
can then cut down and modify to get an initial
class list for the system
IN THIS PARTICULAR CASE WE DISCARD
Library, because it is outside the scope of our system
Short term loan, because a loan is really an event,
which so far as we know is not a useful object in this
system
Member of the library, which is redundant

Week, because it is a measure, not a thing

Item, because it is vague (we need to clarify it)

Time, because it is outside the scope of the system

System, because it is part of the meta-language of


requirements description, not a part of domain
Rule, for the same reason
THIS LEAVES:
Book
Journal

Copy (of book)

Library member

Member of staff
To better understand the noun phrase method,
we will go through a scenario and apply the noun
phrase strategy for identifying the classes.
We must start by reading the use cases and
applying the principles discussed for identifying
classes.
THE BANK ATM SYSTEM:
IDENTIFYING CLASSES BY USING NOUN PHRASE APPROACH

Initial List of Noun Phrases: Candidate Classes

Account Balance PIN Message


Amount PIN Code Money
Approval Process Savings Account Password
ATM Card Step PIN
ATM Machine Currency PIN Code
Bank Dollar Savings Account
Bank Client Envelope Transaction
Card Four Digits Transaction History
Cash Fund
Checking Account Invalid PIN
Client
Client's Account
It is safe to eliminate the irrelevant classes.
The candidate classes must be selected from relevant
and fuzzy classes.
The following irrelevant classes can be eliminated
because they do not belong to the problem statement:
Envelope, Four Digits.
Strikeouts indicate eliminated classes.
THE BANK ATM SYSTEM:
IDENTIFYING CLASSES BY USING NOUN PHRASE APPROACH

Irrelevant classes can be eliminated


REVIEWING THE REDUNDANT CLASSES AND BUILDING
A COMMON VOCABULARY

We need to review the candidate list to see which classes are


redundant. If different words are being used to describe the same
idea, we must select the one that is the most meaningful the
context of the system and eliminate the others.
The following are the different class names that are being used to
refer to the same concept:
Client, BankClient Account, Client's Account PIN, PIN Code
Checking,
Checking Account = BankClient (the term chosen)
Checking Account = Account
Checking Account = PIN
Checking Account = Checking Account
Savings, Savings Account = Savings Account
Fund, Money = Fund
ATM Card, Card = ATM Card
HERE IS THE REVISED LIST OF CANDIDATE CLASSES:
REVIEWING THE POSSIBLE ATTRIBUTES
This focus on identifying the noun phrases that are attributes,
not classes.
The noun phrases used only as values should be restated as
attributes. This process also will help us identify the attributes of
the classes in the system.
Balance: An attribute of the Account class.
Invalid PIN: It is only a value, not a class.
Password: An attribute, possibly of the BankClient class.
Transaction History: An attribute, possibly of the Transaction
class. ..
PIN: An attribute, possibly of the BankClientclass.
Here is the revised list of candidate classes.
Notice that the eliminated classes are strikeouts (they have a line through
them).
REVIEWING THE CLASS PURPOSE
Identifying the classes that play a role in achieving
system goals and requirements is a major activity of
object-oriented analysis)
Each class must have a purpose.

Every class should be clearly defined and necessary in


the context of achieving the system's goals.
If you cannot formulate a statement of purpose for a
class, simply eliminate it.
The classes that add no purpose to the system will be
deleted from the list.
IDENTIFIED CANDIDATE CLASSES
ATMCard class: Provides a client with a key to an account.
BankClient class: A client is an individual that has a checking account and
possibly, a savings account.
Bank class: Bank clients belong to the Bank. It is a repository of accounts
and processes the accounts' transactions.
Account class: An Account class is a formal (or abstract) class, it defines
the common behaviors that can be inherited by more
specific classes such as CheckingAccount and
SavingsAccount.
CheckingAccount class: It models a client's checking account and provides
more specialized withdrawal service.
SavingsAccount class: It models a client's savings account.
Transaction class: Keeps track of transaction, time, date, type, amount,
and balance.
SUMMARY
Remember, there is no such thing as the "right" set of classes.
However, the process of identifying classes can improve gradually
through this incremental process.
The major problem with the noun phrase approach is that it
depends on the completeness and correctness of the available
document, which is rare in real life. On the other hand,large
volumes of text on system documentation might lead to too many
candidate classes.
APPROACH2:COMMON CLASS PATTERNS APPROACH
This approach is based on the knowledge-base of
the common classes that have been proposed by
various researchers.
Aim: patterns for finding the candidate class and
object
CANDIDATE CLASSES :CONCEPT CLASS
A concept is a particular idea or understanding that we
have of our world
Concepts are principles or ideas not tangible(real) but
used to organize or keep track of business activities and
communications.
Ex: performance
CANDIDATE CLASSES - EVENTS
These are points in time that must be recorded and
remembered.
Things happen, usually to something else, at a
given date and time, or as a step in an ordered
sequence.
For example order which an event that must be
remembered.
Ex : landing, order, request
CANDIDATE CLASSES - ORGANIZATION
The organizational units that people belong to.
For example, accounting department might be
considered as a potential class.
A collection of people, resources, facilities, or groups
to which users belong, and their capabilities have a
defined mission, whose existence is largely
independent of individuals.
Ex : human resources department
CANDIDATE CLASSES - PEOPLE AND PERSON
(ROLES AND ROLES PLAYED)
The different roles users play in interacting with
the application.
Known as person, roles, and roles played class

Represents the different roles users play in


interacting with the application
What role does a person play in the system ?

Ex : employee, student, lecturer


CANDIDATE CLASSES - PEOPLE (CONT)

It can be divided into two types (Coad & Yourdon):


Those representing users of the system, such as an
operator, or a clerk;
Those people who do not use the system but about
whom information is kept.
Some examples are Client, Employee, Teacher,
Manager.
CANDIDATE CLASSES - PLACES

These are physical locations, such as buildings,


stores, sites or offices that the system must keep
information about.
Physical locations that the system must keep
information about
Ex : buildings, stores, offices
CANDIDATE CLASSES - TANGIBLE THINGS AND
DEVICES
Physical objects, or group of objects, that are
tangible, and devices with which the application
interacts.
Ex : car (tangible ), pressure sensors (devices)
SUM UP TOGETHER
concept events organisa people places Tangible
tion Things
and
Devices
performance order, HR employee, buildings, car
request department student, stores (tangible ),
lecturer pressure
sensors
(devices)
APPROACH3:USE-CASE DRIVEN APPROACH
The third method to identify classes in a system is
use-case driven approach .

Once the system has been described in terms of its


scenarios, we can examine the textual description
or steps of each scenario to determine what
objects are needed for the scenario to occur.
USE-CASE DRIVEN APPROACH
To identify objects of a system and their behaviors,
the lowest level of executable use cases is further
analyzed with a sequence and collaboration
diagram pair.
By walking through the steps, you can determine
what objects are necessary for the steps to take
place.
USE-CASE DRIVEN APPROACH:
IDENTIFYING CLASSES AND THEIR BEHAVIORS THROUGH
SEQUENCE/COLLABORATION MODELING
Use cases are employed to model the scenarios in the
system and specify what external actors interact with the
scenarios. The scenarios are described in text or through
a sequence of steps.
Use-case modelling is considered a problem-driven
approach to object-oriented analysis, in that the designer
first considers the problem at hand and not the
relationship between objects, as in a data-driven
approach.
Modelling with use cases is a recommended aid in finding
the objects of a system and is the technique used by the
unified approach.
CONTD..
Once the system has been described in terms of its
scenarios, the modeller can examine the textual
description or steps of each scenario to determine what
objects are needed for the scenario to occur.
The process of creating sequence or collaboration
diagrams is a systematic way to think about how a use
case (scenario) can take place; and by doing so, it forces
you to think about objects involved in your application.
IMPLEMENTATION OF SCENARIOS

Each scenario in UML specification shows a different


sequence of interaction between actors and the system,
with all decisions definite.
When you have arrived at the lowest use-case level, you
may create a child sequence diagram or accompanying
collaboration diagram for the use case.
With the sequence and collaboration diagrams, you can
model the implementation of the scenario .
Like use-case diagrams, sequence diagrams are used to
model scenarios in the systems.
Whereas use cases and the steps or textual descriptions
that define them offer a high-level view of a system, the
sequence diagram enables you to model a more specific
analysis and also assists in the design of the system by
modeling the interactions between objects in the system.
CONTD..
In a sequence diagram, the objects involved are drawn
on the diagram as a vertical dashed line, with the name
of the objects at the top.
Horizontal lines corresponding to the events that occur
between objects are drawn between the vertical object
lines.
The event lines are drawn in sequential order, from the
top of the diagram to the bottom. They do not
necessarily correspond to the steps defined for a usecase
scenario.
Interaction Diagrams :
A graphical representation of interactions between objects

2 kinds of interaction diagrams :

1.Sequence diagrams(time ordered)


and
2.Collaboration diagrams (data flow)
SEQUENCE DIAGRAM
Shows object interactions arranged in time sequence
The diagram shows,
The objects participating in the interaction

The sequence of messages exchanged

Basic elements :
Actors : someone/something outside the system that

interacts with the system, either by giving or


receiving information, or both
Objects: an entity with a well-defined boundary and

identity that encapsulates state and behaviour


Messages: communication between two objects that

triggers an event
SEQUENCE DIAGRAM NOTATION
Actor

Class

Synchronous message

Asynchronous message

Focus of Control

Return message

Termination
lifeline
C lie n t A T M M a c h in e B a n k C lie n t

In s e rt A T M c a rd

R e q u e s t P IN

R e q u e s t P IN n u m b e r

V e rify P IN N u m b e r

B a d P IN N u m b e r

B a d P IN N u m b e r
M essage

E je c t A T M c a rd

R e q u e s t ta k e c a rd

T a k e c a rd
D is p la y m a in s c re e n
Bank Client ATM Machine Account Checking Account

Request Kind

Enter Kind

Request Amount
Enter Amount

Process Transaction
Withdraw Checking Account
Transaction succeed Withdraw Successful

Dispense Cash

Request Take Cash


Take Cash
Request Continuation
Terminate
Print Receipt
COLLABORATION DIAGRAM
Alternate way to represent the messages exchanged by a set of
objects
The diagram shows object interactions organized around the
objects and their links to each other
Basic elements :
Actors

Objects

Links : a pathway for communication between objects on

a collaboration diagram
Messages
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 -
PURPOSE

Collaboration diagrams are useful when we want to


refer to a particular interaction.

To illustrate the coordination of object structure and


flow of control.
2: Enter Kind
5: Process Transaction
4: Enter Amount
13: Terminate
Account ATM Machine:Definition Bank Client

8: Transaction succeed
1: Request Kind
3: Request Amount
9: Dispense Cash
10: Request Take Cash
7: Withdraw Successful 6: Withdraw Checking Account
11: Take Cash
12: Request Continuation
Checking Account 14: Print Receipt
COLLABORATION DIAGRAM
COLLABORATION DIAGRAM VS
SEQUENCE DIAGRAM

Both show the interaction between the objects\classes.

If time is the most important aspect to emphasize,


choose sequence diagrams.
If the role is the most important aspect to emphasize,
choose collaboration diagram
THE BANK ATM SYSTEM: DECOMPOSING

Scenario with a Sequence Diagram:


A sequence diagram represents the sequence and
interactions of a given use case or scenario.
Sequence diagrams are among the most popular UML
diagrams and, if used with an object model or class
diagram, can capture most of the information about a
system .
Most object-to-object interactions and operations are
considered events, and events include signals, inputs,
decisions, interrupts, transitions, and actions to or from
users or external devices.
CONTD..
An event also is considered to be any action by an object that sends
information.
The event line represents a message sent from one object to
another, in which the "from" object is requesting an operation be
performed by the "to" object.
The "to" object performs the operation using a method that its class
contains.
Developing sequence or collaboration diagrams requires us to think
about objects that generate these events and therefore will help us
in identifying classes.
To identify objects of a system, we further analyze the lowest level
use cases with a sequence and collaboration diagram pair .
Sequence and collaboration diagrams represent the order in which
things occur and how the objects in the system send messages to
one another. These diagrams provide a macro-level analysis of the
dynamics of a system.
SEQUENCE DIAGRAMS

You can draw sequence diagrams to model each


scenario that exists when a BankClient withdraws,
deposits, or needs information on an account.
By walking through the steps, you can determine what
objects are necessary for those steps to take place.
Therefore, the process of creating sequence or
collaboration diagrams can assist you in identifying
classes or objects of the system.
This approach can be combined with noun phrase and
class categorization for the best results.
EXAMPLE:
IDENTIFY THE USE CASES FOR THE BANK SYSTEM

The following are the low level (executable) use cases:


Deposit Checking
Deposit Savings
Invalid PIN
Withdraw Checking
Withdraw More from Checking
Withdraw Savings
Withdraw Savings Denied
Checking Transaction History
Savings Transaction History
Let us create a sequence/collaboration diagram for the following use
cases:
Invalid PIN use case .

Withdraw Checking use case .

Withdraw More from Checking

Use case Sequence/collaboration diagrams are associated with a use


case.
For example, to model the sequence/collaboration diagrams, you
must first select a use case such as the Invalid PIN use case, then
associate a sequence or collaboration child process.
To create a sequence you must think about the classes that
probably will be involved in a use-case scenario.
Keep in mind that use case refers to a process, not a class.

However, a use case can contain many classes, and the same class
can occur in many different use cases.
Consider how we would prepare a sequence diagram for the
Invalid PIN use case.
Here, we need to think about the sequence of activities that the
actor BankClient performs: . Insert ATM Card. .Enter PIN
number. . Remove the ATM Card.
Based on these activities, the system should either grant the
access right to the account or reject the card. Next, we need to
more explicitly define the system.
With what are we interacting? We are interacting with an
ATMMachine and the BankClient. So, the other objects of this use
case are ATMMachine and BankClient.
Now that we have identified the objects involved in the use case,
we need to list them in a line along the top of a page and drop
dotted lines beneath each object (see Figure ).
The client in this case is whoever tries to access an account
through the ATM, and may or may not have an account. The
BankClient on the other hand has an account.
The dotted lines are the lifelines. The line on the right represents an
actor, in this case the Bank Client or an event that is outside the
system boundary.
An event arrow connect objects.
In effect, the event arrow suggests that a message is moving between
those two objects.
An example of an event message is the request for a PIN.
An event line can pass over an object without stopping at that object.
In some cases, several objects are active simultaneously, even if they
are only waiting for another object to return information to them.
In other cases, an object becomes active when it receives a message
and then becomes inactive as soon as it responds . Similarly, we can
develop sequence diagrams for other use cases (as in Figures ).
COLLABORATION DIAGRAM
Collaboration diagrams are just another view of the
sequence diagrams and therefore can be created
automatically; most UML modeling tools automatically
create them (see Figures )
The following classes have been identified by modeling
the UML sequence/collaboration diagrams:
Bank, BankClient, ATMMachine, Account, Checking
Account and Savings Account.
Similarly other classes can be identified by developing
the remaining sequence/ collaboration diagrams.
COLLABORATION DIAGRAM
THE COLLABORATION DIAGRAM FOR THE WITHDRAW MORE FROM
CHECKING -USE CASE
APPROACH4:CRC CARDS
CRC stands for Class, Responsibilities and
Collaborators developed by Cunningham, Wilkerson
and Beck.
CRC cards as a viable alternative to UML sequence
diagram to design the dynamics of object interaction
and collaboration
CRC is a brainstorming tool used in the design of
object-oriented software
CRC can be used for identifying classes and their
responsibilities.
By identifying an objects responsibilities and
collaborators, you can identify its attributes and
methods
PROCESS OF THE CRC TECHNIQUE

Identify
Classes
responsibility

Iterate

Identify Assign
Collaboration responsibility
CONTD
Classes are identified and grouped by common attributes which
also provides candidates for super classes.
The class names then are written onto Classes, Responsibilities,
and Collaborators cards. The card also notes sub- and super
classes to show the class structure.
The application's requirements then are examined for actions
and information associated with each class to find the
responsibilities of each class.
Next, the responsibilities are distributed; they should be as
general as possible and placed as high as possible in the
inheritance hierarchy.
The idea in locating collaborators is to identify how classes
interact.
Classes (cards) that have a close collaboration are grouped
together physically.
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
CRC cards are usually created from index cards.
Members of a brainstorming session will write up one
CRC card for each relevant class/object of their design.
The card is partitioned into three areas:
On top of the card, the class name

On the left, the responsibilities of the class

On the right, collaborators (other classes) with which


this class interacts to fulfil its responsibilities
CRC CARDS (CONT)

CRC cards are index cards. All the information for


an object is written on a card.

ClassName
...
Collaborators

...
Responsibilities
EXAMPLE1 :ATM SYSTEM
CONTD..
The class name should appear in the upper left-hand
corner, a bulleted list of responsibilities should appear
under it in the left two thirds of the card, and the list of
collaborators should appear in the right third.
However, rather than simply tracing the details of a
collaboration in the form of message sending, Classes,
Responsibilities and Collaborators cards place the
designer's focus on the motivation for collaboration by
representing (potentially) many messages as phrases of
English text.
CRC CARDS (CONT)

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.
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.
EXAMPLE: BANK ATM SYSTEM
The objective of this example is to identify objects'
responsibilities such as attributes and methods in that
system.
Account and Transaction provide the banking model.
Note:
Assume an active role while money is being dispensed and
a passive role thereafter. The class Account is responsible
mostly to the BankClient class and it collaborates with
several objects to fulfill its responsibilities.
Among the responsibilities of the Account class to the
BankClient class is to keep track of the BankClient
balance, account number and other data that need to be
remembered. These are the attributes of the Account
class.
Furthermore, the Account class provides certain services
or methods, such as means for BankClient to deposit or
withdraw an amount and display the account's Balance
(see Figure ).
Classes, Responsibilities, and Collaborators encourages
team members to pick up the card and assume a role
while "executing" a scenario.
It is not unusual to see a designer with a card in each
hand, waving them about, making a strong identification
with the objects while describing their collaboration.
Ward Cunningham writes: Classes, Responsibilities,and
Collaborators cards work by taking people through
programming episodes together.
As cards are written for familiar objects, all participants
pick up the same context and ready themselves for decision
making.
Finally, the group starts to relax as consensus has been
reached and the issue becomes simply finding the right
words to record a decision as a responsibility on a card.
In similar fashion other cards for the classes that have been
identified earlier in this chapter must be created, with the
list of their responsibilities and their collaborators.
As you can see from Figure , this process is iterative. Start
with few cards (classes) then proceed to play "what if."
If the situation calls for a responsibility not already covered
by one of the objects, either add the responsibility to an
object or create a new object to address that responsibility.
EXAMPLE FOR CRC-ATM
Click for the detailed explanation for CRC-ATM
SUMMARY (CONT)
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.

You might also like