Ooad Ooad3unit
Ooad Ooad3unit
• Object Analysis
• Classification Unit-3
• Identifying Object relationships
• Attributes and Methods.
Agenda
• Identifying Use Cases
• Object Analysis: Classification
• Identifying object relationships, Attributes
and Methods.
1.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 system’s requirements.
Analysis
• 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 (Con’t)
• 2. Develop a simple business process
model using UML activity diagram.
The OOA Process (Con’t)
• 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?
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
Test1 Test3
Implemented by Test2
Realized by
Use cases Test
Specified by Design1
Design2
Design4
Design3
Implementation
Design
Analysis
Use Case Model (Con’t)
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)
80%-20%
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
Class
Synchronous message
Asynchronous message
Focus of Control
Return message
Termination
lifeline
Client ATMMachine BankClient
Request PIN
Take card
Display main screen
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
• 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
Customer Operator
Order
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.
Grand Parent
John of Ken
Parent Parent
of Brian of
John Ken
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
Multiple Inheritance
aggregation. This meta
model reflects this
situation.
Carburetor
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
Football Team
Player
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
domain and the real
world to find them.
Guidelines For Identifying
Attributes Of Classes (Con’t)
• Omit derived attributes.
• For example, don't use age as an attribute
since it can be derived from date of birth.
• Drive attributes should be expressed as a
method.
Guidelines For Identifying
Attributes Of Classes (Con’t)
• Do not carry discovery of attributes to
excess.
• You can always add more attributes in the
subsequent iterations.
Object Responsibility: Methods
& Messages
• Methods and messages are the work
horses of object-oriented systems.
• In O-O environment, every
piece of data, or object,
is surrounded by a rich set
of routines called methods.
Identifying Methods by
Analyzing UML Diagrams and
Use Cases
• Sequence diagrams can assist us in
defining the services the objects must
provide.
Identifying Methods (Con’t)
ATM Ac c ount
Bank C lient C hec k ing Ac c ount
Mac hine
R eques t Kind
Enter Kind
R eques t Amount
Enter Amount
D is pens e C as h
R eques t Tak e C as h
Tak e C as h
R eques t C ontinuation
Ter minate
Print R ec eipt
Identifying Methods (Con’t)
• Methods usually correspond to queries
about attributes (and sometimes
association) of the objects.
• Methods are responsible for managing
the value of attributes such as query,
updating, reading and writing.
Identifying Methods (Con’t)
• For example, we need to ask the
following questions about soup class:
• What services must a soup class
provide? And
• What information (from domain
knowledge) is soup class responsible
for storing?
Identifying Methods (Con’t)
• Let's first take a look at its attributes
which are:
• name
• preparation,
• price,
• preparation time and
• oven temperature.
Identifying Methods (Con’t)
• Now we need to add methods that can
maintain these attributes.
• For example, we need a method to
change a price of a soup and another
operation to query about the price.
Identifying Methods (Con’t)
• setName
• getName
• setPreparation
• get Preparation
• setCost
• getCost
• setOvenTemperature
• getOvenTemperature
• setPreparationTime
• getPreparationTime
Summary
• We learned how to identify three types
of object relationships:
• Association
• Super-sub Structure (Generalization
Hierarchy)
• A-part-of Structure
Summary (Con’t)
• The hierarchical relation allows the sharing
of properties or inheritance.
• A reference from one class to another is an
association.
• The A-Part-of Structure is a special form of
association.
Summary (Con’t)
• Every class is responsible for storing
certain information from domain
knowledge .
• Every class is responsible for performing
operations necessary upon that
information.