L12 ObjectModeling Ch05lect1
L12 ObjectModeling Ch05lect1
L12 ObjectModeling Ch05lect1
Object Modeling
Chapter 5: Analysis,
Outline
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 2
From Use Cases to Objects
Level 1 Level 1 Use Case
Operations
Level 4 Level 4
A B
Participating
Objects
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 3
From Use Cases to Objects: Why Functional
Decomposition is not Enough
Level 1 Scenarios
Operations
Level 4 Level 4
A B
Participating
Objects
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 4
Activities during Object Modeling
Main goal: Find the important abstractions
Steps during object modeling
1. Class identification
Based on the fundamental assumption that we can
find abstractions
2. Find the attributes
3. Find the methods
4. Find the associations between classes
Order of steps
Goal: get the desired abstractions
Order of steps secondary, only a heuristic
What happens if we find the wrong abstractions?
We iterate and revise the model
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 5
Class Identification
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 6
Class Identification
Approaches
Application domain approach
Ask application domain experts to identify relevant
abstractions
Syntactic approach
Start with use cases
Analyze the text to identify the objects
Extract participating objects from flow of events
Design patterns approach
Use reusable design patterns
Component-based approach
Identify existing solution classes.
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 7
Class identification is a Hard Problem
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 8
There are different types of Objects
Entity Objects
Represent the persistent information tracked by the
system (Application domain objects, also called
Business objects)
Boundary Objects
Represent the interaction between the user and the
system
Control Objects
Represent the control tasks performed by the system.
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 9
Example: 2BWatch Modeling
To distinguish different object types
in a model we can use the
UML Stereotype mechanism
Year Button
ChangeDate
Month
LCDDisplay
Day
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 10
Naming Object Types in UML
UML provides the stereotype mechanism to
introduce new types of modeling elements
A stereotype is drawn as a name enclosed by angled double-
quotes (guillemets) (<<, >>) and placed before the name of a
UML element (class, method, attribute, .)
Notation: <<String>>Name
<<Entity>> <<Boundary>>
Year <<Control>> Button
ChangeDate
<<Entitity>>
Month <<Boundary>>
<<Entity>> LCDDisplay
Day
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 12
Icons for Stereotypes
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 13
Graphics for Stereotypes
One can also use graphical symbols to identify a
stereotype
When the stereotype is applied to a UML model element, the
graphic replaces the default graphic for the diagram element.
Example: When modeling a network, define graphics for
representing classes of type Switch, Server, Router, Printer,etc.
Graphics for
Class of type
Router
Graphics for
Class of type Graphics for
Switch Server Class
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 14
Pros and Cons of Stereotype Graphics
Advantages:
UML diagrams may be easier to understand if they contain
graphics and icons for stereotypes
This can increase the readability of the diagram, especially
if the client is not trained in UML
And they are still UML diagrams!
Disadvantages:
If developers are unfamiliar with the symbols being used, it can
become much harder to understand what is going on
Additional symbols add to the burden of learning to read the
diagrams.
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 15
Object Types allow us to deal with Change
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 16
Finding Participating Objects in Use Cases
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 18
Mapping parts of speech to model
components (Abbots Technique)
Example Part of speech UML model component
Monopoly Proper noun object
Toy Improper noun class
Buy, recommend Doing verb operation
is-a being verb inheritance
has an having verb aggregation
must be modal verb constraint
dangerous adjective attribute
enter transitive verb operation
depends on intransitive verb Constraint, class,
Bernd Bruegge & Allen H. Dutoit
association 19
Object-Oriented Software Engineering: Using UML, Patterns, and Java
Generating a Class Diagram from Flow of Events
Customer Flow of events:
The customer enters the store
store
? to buy a toy.
toy It has to be a
toy that his daughter likes and
enter() it must cost less than 50 Euro.
videogame which
He tries a videogame,
daughter uses a data glove and a head-
age mounted display. He likes it.
suitable An assistant helps him. The
*Toy depends
suitability of the game depends
toy
price on the age of the child. His
buy()
buy() daughter is only 3 years old.
like() The assistant recommends another
type of toy
toy, namely a boardgame.
boardgame
videogame boardgame
The customer buy the game and
leaves the store
Ways to find Objects
Syntactical investigation with Abbots technique:
Flow of events in use cases
Problem statement
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 21
Order of Activities for Object Identification
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 22
Steps in Generating Class Diagrams
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 23
Who uses Class Diagrams?
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 24
Who does not use Class Diagrams?
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 25
Summary
System modeling
Functional modeling+object modeling+dynamic modeling
Functional modeling
From scenarios to use cases to objects
Object modeling is the central activity
Class identification is a major activity of object modeling
Easy syntactic rules to find classes and objects
Abbots Technique
Class diagrams are the center of the universe
for the object-oriented developer
The end user focuses more on the functional model and
and usability.
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 26
Additional Slides
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 27
What is This?
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 28
What is This?
Face
1..2
Eye
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 29
Modeling in Action
If it is a Face
What are its Attributes?
Sad, Happy
Or is it a Mask?
Investigate the
functional model
Who is using it? -> Actors
Art collector
Bankrobber
Carnival participant
How is it used? -> Event flow
Napkin design of a Mask to be used at the
Venetian Carnival
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 30
Pieces of an Object Model
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 31
Associations
Types of Associations
Canonical associations
Part-of Hierarchy (Aggregation)
Kind-of Hierarchy (Inheritance)
Generic associations
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 32
Attributes
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 33
Operations
Source of operations
Use cases in the functional model
General world knowledge
Generic operations: Get/Set
Design Patterns
Application domain specific operations
Actions and activities in the dynamic model
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 34
Object vs Class
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 35
Developers have different Views on Class
Diagrams
According to the development activity, a
developer plays different roles:
Analyst
System Designer
Object Designer
Implementor
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 36
The View of the Analyst
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 37
The View of the Designer
The designer focuses on the solution of the
problem, that is, the solution domain
The associations between classes are now
references (pointers) between classes in the
application or solution domain
An important design task is the specification of
interfaces:
The designer describes the interface of classes and the
interface of subsystems
Subsystems originate from modules (term often used
during analysis):
Module: a collection of classes
Subsystem: a collection of classes with an interface
Subsystems are modeled in UML with a package.
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 38
Goals of the Designer
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 39
The View of the Implementor
Class implementor
Must realize the interface of a class in a programming
language
Interested in appropriate data structures (for the
attributes) and algorithms (for the operations)
Class extender
Interested in how to extend a class to solve a new
problem or to adapt to a change in the application
domain
Class user
The class user is interested in the signatures of the
class operations and conditions, under which they can
be invoked
The class user is not interested in the implementation
of the class.
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 40
Why do we distinguish different Users of
Class Diagrams?
Models often dont distinguish between
application classes and solution classes
Reason: Modeling languages like UML allow the use of
both types of classes in the same model
address book, array"
Preferred: No solution classes in the analysis model
Many systems dont distinguish between the
specification and the implementation of a class
Reason: Object-oriented programming languages allow
the simultaneous use of specification and
implementation of a class
Preferred: We distinguish between analysis model and
object design model. The analysis design model does
not contain any implementation specification.
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 41
Analysis Model vs. Object Design model
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 42
Analysis Model vs Object Design Model (2)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 43
Summary 2
System modeling
Functional modeling+object modeling+dynamic modeling
Functional modeling
From scenarios to use cases to objects
Object modeling is the central activity
Class identification is a major activity of object modeling
Easy syntactic rules to find classes and objects
Abbots Technique
Analysts, designers and implementors have
different modeling needs
There are three types of implementors with
different roles during
Class user, class implementor, class extender.
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 44