OBJECT ORIENTED
ANALYSIS
( Class Diagram - Part 2 )
Lecture 3
CMP120130 Object Oriented Modeling & Design 1
AGENDA
🞭 Object Oriented Analysis
🞤 Identifying Classes
🞫 Noun and Verb Method
🞫 Class Responsibility and Collaboration (CRC)
Cards.
🞭 UML Class Diagrams
CMP120130 Object Oriented Modeling & Design 2
OO DESIGN – WHERE TO START
🞭 “Do not begin an OO design until at least part of the
use case model has been specified”
🞭 The Use Case Model:
🞤 provides clues about the required classes and
their functionality;
🞤 it will also hint at how the resulting objects
should interact.
🞭 The use case scenarios drive the OO design.
CMP120130 Object Oriented Modeling & Design 3
OBJECT ORIENTED ANALYSIS
🞭 Discover Classes for the requirements.
1. Noun Analysis
2. Use Case Analysis
3. CRC Method
CMP120130 Object Oriented Modeling & Design 4
DISCOVERING CLASSES
1. NOUN ANALYSIS
CMP120130 Object Oriented Modeling & Design 5
NOUN VERB ANALYSIS
🞭 A simple recipe
🞤 Step 1:
We can identify objects in our problem
statement by looking for nouns and noun phrases.
🞤 Step 2:
Each of these can be underlined and
becomes a candidate for an object in our solution.
🞤 Step 3: We can eliminate some objects by some
simple rules.
CMP120130 Object Oriented Modeling & Design 6
RULES FOR REJECTING NOUNS
1. Redundant
2. Vague
3. An event or an operation
4. Outside scope of system
5. Meta-language
6. An attribute
CMP120130 Object Oriented Modeling & Design 7
ACTIVITY 1
🞂 In a DVD rental store there are two types of users, a
registered member can borrow up to 3 DVDs at a time.
These members have already paid a deposit and only
need to pay 50/= per DVD.
🞂 Customers who are not registered can also borrow
DVDs at the rate of 75/= per DVD. They are required
to surrender their id card for this purpose.
🞂 Members can keep the DVD for three days and when
they are returned appropriate fines may be calculated.
CMP120130 Object Oriented Modeling & Design 8
ACTIVITY 1
🞂 In a DVD rental store there are two types of users, a
registered member can borrow up to 3 DVDs at a time.
These members have already paid a deposit and only
need to pay 50/= per DVD.
🞂 Customers who are not registered can also borrow
DVDs at the rate of 75/= per DVD. They are required
to surrender their id card for this purpose.
🞂 Members can keep the DVD for three days and when
they are returned appropriate fines may be calculated.
CMP120130 Object Oriented Modeling & Design 9
ACTIVITY 1 ANSWER :
🞭 DVD - class Final Classes ?
⚫ DVD
🞭 User
Redundant ⚫ Reg. Member DVD
🞭 Customer ⚫ Un reg. Member
🞭 Member Meta language
🞭 ID Card – ID number is an Member
attribute
🞭 Fine - Name
Attribute
🞭 Deposit –
Attribute / operation
🞭 Store - Reg.Member
Un-reg. Member
Out of scope
🞭 Rate - ID number
Attribute
CMP120130 Object Oriented Modeling & Design 1
0
ACTIVITY 2
AIRLINE RESERVATION SYSTEM
‘Tour-Lanka Airlines’ runs sightseeing flights from Colombo, the
capital of Sri Lanka. The reservation system keeps track of
passengers who will be flying in specific seats on various
flights, as well as people who will form the crew.
For the crew, the system needs to track what everyone does,
and who supervises whom. Tour-Lanka Airlines runs several
daily numbered flights on a regular schedule. Tour-Lanka
Airlines expects to expand in the future so that system needs
to be flexible, in particular, it will be adding a frequent flyer
plan.
CMP120130 Object Oriented Modeling & Design 1
1
ACTIVITY 2
AIRLINE RESERVATION SYSTEM
‘Tour-Lanka Airlines’ runs sightseeing flights from Colombo,
the capital of Sri Lanka. The reservation system keeps track
of passengers who will be flying in specific seats on various
flights, as well as people who will form the crew.
For the crew, the system needs to track what everyone does,
and who supervises whom. Tour-Lanka Airlines runs several
daily numbered flights on a regular schedule. Tour-Lanka
Airlines expects to expand in the future so that system
needs to be flexible, in particular, it will be adding a
frequent flier plan.
CMP120130 Object Oriented Modeling & Design 1
2
Other Nouns Classes
🞭 Flight
• Reservation system – it is the system. 🞤 Sightseeing flight
• Sightseeing flight –Better take „flight‟. its is 🞭 Passenger
more general and lead to flexibility 🞭 Employee
• Seat – attribute of flight 🞤 crewmember
• Crew –They are employees (can have a sub
class „Crewmember‟)
• Schedule – composite information bundle>
can be managed with attributes of flight class
• Future – not part of current scope
Frequent flier plan –not part of current scope
Tour-Lanka Airlines – It is the system
Colombo – instance
Sri Lanka - instance
CMP120130 Object Oriented Modeling & Design 1
3
DISCOVERING CLASSES
2. USE CASE ANALYSIS
CMP120130 Object Oriented Modeling & Design 1
4
USE CASE ANALYSIS
🞭 Consider the above use case : Update
🞤 The user interacts with the system to perform
an „update‟.
🞤 The system interacts with the database.
CMP120130 Object Oriented Modeling & Design 15
USE CASE ANALYSIS
🞭 Look into the use case further:
There are some classes: C1, C2, C3
There are some methods: M1,M2,M3, etc…
CMP120130 Object Oriented Modeling & Design 16
USE CASE ANALYSIS
1. Determine what classes are needed, without
accidentally picking:
⚫ there is an infinite number of classes to choose from.
2. Determine the responsibilities of the classes.
⚫ i.e. what they are supposed to do:
⚫ there are no limitations on the functionality of a class!
3. Define the collaborations between classes:
⚫ i.e. the relationships between them.
CMP120130 Object Oriented Modeling & Design 17
USE CASE ANALYSIS
🞭 Once the basic scenarios have been developed for the
system, it is time to identify candidate classes and
indicate their responsibilities and collaborations.
🞭 There are ways to make this easier.
▪ Patterns.
▪ Experience.
▪ CRC Cards.
CMP120130 Object Oriented Modeling & Design 18
DISCOVERING CLASSES
3. CRC CARDS METHOD
CMP120130 Object Oriented Modeling & Design 1
9
🞭 Class Responsibility and
Collaboration (CRC) cards:
🞤 developed by Beck and
Cunningham (1989).
🞭 Used to explore class relationships
between classes in a particular use-
case scenario.
CMP120130 Object Oriented Modeling & Design 20
🞂 A CRC is a 4 × 6 inch card divided into three
sections.
◦ The name of the class on the top of the card.
◦ The responsibilities of the class on the left of the card.
◦ The class collaborations on the right of the card.
(the list of other classes with which the class collaborates to
realize its responsibilities)
CMP120130 Object Oriented Modeling & Design 21
WHAT IS A RESPONSIBILITY ?
🞂 A responsibility is something that class has to
🞂 Know OR Do
🞂 A card may have one or more responsibilities
🞂 The list of responsibilities on the CRC card is
not the list of methods in the class.
◦ A responsibility may be realized by several methods.
◦ A responsibility may require multiple collaborations.
CMP120130 Object Oriented Modeling & Design 2
2
🞂 A class may not be able to act upon
its responsibility on its own.
🞂 It may require some interaction with
other classes.( need help )
🞤 these helper classes are the
collaborators.
CMP120130 Object Oriented Modeling & Design 232
3
🞭 The easiest way to generate CRC cards is by using the
scenarios in the use case model. No need to examine ALL
scenarios, just a representative sample.
🞭 The cards are used to “role play” each scenario
Set of use case Set of CRCs
Use case scenarios
CMP120130 Object Oriented Modeling & Design 242
4
🞂 Each scenario adds to the responsibilities
and collaborations on several CRC cards.
🞂 When you consider all scenarios for all use cases:
◦ You have a set of CRC cards (indicating all the classes your
system requires to realize the use cases).
◦ For each CRC card, you will have the list of all
responsibilities the class realizes.
◦ For each responsibility, you will have the list of all
collaborating classes.
CMP120130 Object Oriented Modeling & Design 25
CRC CARDS – EXAMPLE
🞭 An example of one responsibility requiring
multiple collaborations.
🞭 The DatabaseInterface Class is
responsible for updating the enrolment.
🞭 It collaborates with the Student, Unit
and Course classes to realize this
responsibility.
CMP120130 Object Oriented Modeling & Design 26
CRC CARDS – EXAMPLE
Depends on
Independent ( empty )
🞭 The Student class has a responsibility that is
required by the DatabaseInterface class.
🞭 Student class does not require DatabaseInterface
to realize its responsibility.
CMP120130 Object Oriented Modeling & Design 27
CRC - EXAMPLE
🞭 One responsibility may requires several
methods to realize it.
🞭 To “update enrolment” the
DatabaseInterface class must call
several methods in other classes.
CMP120130 Object Oriented Modeling & Design 28
Activity 3:
SCENARIO STEP :
"YOU (THE STUDENT) E-MAIL YOUR RESUME TO
YOU’RE MY (LECTURER’S) BOSS ”
Resume
Student
Lecturer
Boss
W
29rite few CRC cards for this
CMP120130 Object Oriented Modeling & Design 2
9
Steps
1. Take these as the classes for (the first) cards.
Student, Resume , Boss, Lecturer
2. The only verb you need to make this scenario happen is
"send an e-mail with attachment"
3. Add that as a responsibility to the “Student" card.
However, Student can not do this activity alone.
(because the card doesn‟t have enough information).
So, Student needs two collaborators/helpers :
Have to attach The resume > student should have a Resume
Find boss’s e-mail address. > student should ask Lecturer
CMP120130 Object Oriented Modeling & Design 3
0
Activity 1: Basic CRC Cards
Student Resume
Responsibility Collaborators
Responsibility Collaborators
e-mail Resume resume
to a given e-
mail address. Know resume
lecturer details
find e-mail
address.
Boss Lecturer
Responsibility Collaborators Responsibility Collaborato
rs
Know e-mail Get boss's e-mail Boss
address address.
CMP120130 Object Oriented Modeling & Design 3
1
CRC CARDS – WHY BOTHER?
🞭 CRC card generation usually results in
multiple cards, each representing a class.
🞭 From the set of cards, it makes sense to.
🞤 Group classes with similar responsibilities.
🞫 Example: All the classes with database functionality.
🞤 Group classes that collaborate together.
🞫 Example: Entity classes with data classes.
🞤 The groupings are sometimes conflicting.
CMP120130 Object Oriented Modeling & Design 32
CRC CARDS – WHY BOTHER?
🞭 A collaboration graph can be constructed
from the CRC cards.
🞭 This helps to identify sub-systems - sets of
classes that tend to collaborate with each
other.
🞭 CRC cards are the starting point for drawing
class diagrams.
CMP120130 Object Oriented Modeling & Design 33
CRC CARDS – SOME IMPORTANT POINTS
▪ Classes that collaborate with each other are
candidates for an association relationship.
▪ Classes that share overlapping responsibilities are
candidates for a generalization relationship.
▪ Classes that offer functionality using other classes
are candidates for composition /aggregation
relationships.
CMP120130 Object Oriented Modeling & Design 34