CH 4
CH 4
Chapter-5
Analysis
Definition: Object Modeling
2
Class Identification
• Identify the boundaries of the system
• Identify the important entities in the system
• Class identification is crucial to object-oriented modeling
• Basic assumption:
1. We can find the classes for a new software system (Forward Engineering)
2. We can identify the classes in an existing system (Reverse Engineering)
3
Pieces of an Object Model
• Classes
• Associations (Relations)
• Part of- Hierarchy (Aggregation)
• Kind of-Hierarchy (Generalization)
• Attributes
• Detection of attributes
• Application specification
• Attributes in one system can be classes in another system
• Turning attributes to classes
• Methods
• Detection of methods
• Domain Methods: Dynamic model, Functional model
5
Object vs Class
• Object (instance): Exactly one thing
• A class describes a group of objects with similar properties
• Object diagram: A graphic notation for modeling objects,
classes and their relationships ("associations"):
• Class diagram: Template for describing many instances of data.
Useful for taxonomies, patterns, schemata...
• Instance diagram: A particular set of objects relating to each other.
Useful for discussing scenarios, test cases and examples
6
UML: Class and Instance Diagrams
Instance Diagram
7
Attributes and Values
Inspector
name:string
age: integer
8
Links and Associations
• Links and associations establish relationships among objects and
classes.
• Link:
• A connection between two object instances. A link is like a tuple.
• A link is an instance of an association
• Association:
• Basically a bidirectional mapping.
• One-to-one, many-to-one, one-to-many,
• An association describes a set of links like a class describes a set of objects.
9
1-to-1, 1-to-many & many-to-many Associations
One-to-one association
StickyNote
Workorder
* x: Integer
y: Integer
schedule() One-to-many association z: Integer
Mechanics Plane
* Work on *
Many-to-Many Association
10
Aggregation
• Models "part of" hierarchy
• Useful for modeling the breakdown of a product into its component
parts (sometimes called bills of materials (BOM) by manufacturers)
• UML notation: Like an association but with a small diamond indicating
the assembly end of the relationship.
11
Aggregation
Automobile
Engine serial number
horsepower year
volume manufacturer
model
on color
off weight
drive
purchase
3,4,5 * 2,4
12
Inheritance
• Models "kind of" hierarchy
• Powerful notation for sharing similarities among classes
while preserving their differences
• UML Notation: An arrow with a triangle
Cell
14
Object Modeling: Identifying Entity Objects
15
Object Modeling: Identifying Boundary Objects
18
Identifying Control Objects
• Control objects are responsible for coordinating boundary and entity
objects
• Control objects usually do not have a concrete counterpart in the real
world
• a control object is usually created at the beginning of a use case and
ceases to exist at its end.
• It is responsible for collecting information from the boundary objects
and dispatching it to entity objects
• Heuristics for identifying control objects:
• Identify one control object per use case.
• Identify one control object per actor in the use case.
• The life span of a control object should cover the extent of the use case or the
extent of a user session. 19
Object Modeling in Practice: A Banking System
Account
Balance Customer
*
AccountId
Bank Has
Name
Name Deposit() CustomerId
Withdraw()
GetBalance()
Account
Bank Customer
* Balance *
Name AccountId Has Name
Deposit()
Withdraw()
GetBalance() CustomerId
22
Sequence Diagram
• A sequence diagram is a graphical description of the objects
participating in a use case
• Heuristic for finding participating objects:
• An event always has a sender and a receiver
• Find them for each event => These are the objects participating in the use
case.
23
Mapping Use Cases to Objects with
Sequence Diagrams
• A sequence diagram ties use cases with objects.
• It shows how the behavior of a use case (or scenario) is distributed
among its participating objects.
• Sequence diagrams are usually not as good a medium for
communication with the user as use cases are,
• A Sequence diagram requires more background about the notation
which makes it difficult to be understood by the user
• Sequence diagrams allow developers to find missing objects or grey
areas in the requirements specification
• Sequence diagrams model the sequence of interactions among
objects needed to realize the use case
24
Use cases .. To Sequence diagram
26
SEQUENCE DIAGRAMS
• shows the interactions among objects arranged in time sequence
message
activation return
time (optional)
lifeline
27
Sequence diagram…
:NewRegistrationButton :RegistrationForm
<<UI>> :RegistrationControll : Member
:Personnel
:Member <<UI>> :PayrooSection
• Want to Register()
Press Button()
Creat() Creat()
Fill()
Submit()
Validate()
Creat()
Acknowledge()
Message()
Report()
28
SEQUENCE DIAGRAMS (cont’d)
objects go across horizontally and can be named or anonymous
• first column –> the actor who initiates the use case
• second column –> a boundary object (that the actor uses to initiate the use
case)
• third column –> the control object that manages the use case