Se Unit 5
Se Unit 5
Presented By:
Satish Kumar Alaria
Department of CSE/IT
Subject: Software Engineering
Object-Oriented Analysis and Design
• Design review
• Object Modeling Technique
• Object-Oriented Analysis
• Object-Oriented Design
• Three models
• Object model
• Dynamic model
• Functional model
• Four phases
Design - Review
• Object-Oriented Methodology
• development approach used to build complex systems using the
concepts of object, class, polymorphism, and inheritance with a
view towards reusability
• encourages software engineers to think of the problem in terms
of the application domain early and apply a consistent approach
throughout the entire life-cycle
• Object-Oriented Analysis and Design
• analysis models the “real-world” requirements, independent of
the implementation environment
• design applies object-oriented concepts to develop and
communicate the architecture and details of how to meet
requirements
Object Modeling Technique Process via UML (OMT
turned into UML)
• OMT [Rumbaugh et al.,1991] consists of
• building three complementary models of the system
• adding implementation details to the models
• implementing the models
• OMT includes a set of
• phases [processes]
• diagramming techniques
• OMT has four phases
• object-oriented analysis builds a real-world model
• system design determines overall architecture of system
• object design decides upon data structures and algorithms
• implementation translates design into programming
language
OMT Stages and Models
(dataflow diagrams)
Functional Model
- Overall architecture (sub-
Dynamic Model
(state diagrams)
(object diagram)
Object Model
systems)
Object Design
- Refinement of Design
- Algorithms/data structures to
implement each class
Implementation
- Translation of object classes
time
and
relationships to a particular
object-oriented language
System
Introduction to Object-Oriented Analysis
• Class Modeling
• Dynamic Modeling
• Functional Modeling
• Add Operations to the Class Model
• Iterate and refine the models
• After the first iteration, steps may occur in parallel
or out of order
• All models must be kept in synch as changes are made
Class Modeling
Class Name
Class
attribute_1: data_type_1 = default_1
attribute_2: data_type_2 = default_2
...
attribute_m: data_type_m =
default_m
(Class Name)
Person (Person)
(Person)
Mary Wilson
age=27
weight=121
Inheritance
Generalization
Superclass
Class Ball
Attributes Radius, Weight
Operations Throw, Catch
Subclasses
Specialization
Association and Links
equivalent
Company Person
Employs
Employer Employee
Canada Ottawa
Austria Vienna
Multiplicity of Associations
Instructor Courses
1+ Teaches
Takes
6-65
Student
name name
address
salary
job title
Aggregation
Window
Microcomputer
1+
1+ 1+
FastData Inc. wants a subsystem to process office supply orders via the Web.
The user will supply via a form their name, password, account number, and a
list of supplies along with an indication of the quantities desired. The
subsystem will validate the input, enter the order into a database, and
generate a receipt with the order number, expected ship date, and the total
cost of the order. If the validation step fails, the subsystem will generate an
error message describing the cause of the failure.
Purpose of Example
response
1+
• Class Modeling
• Dynamic Modeling
• Functional Modeling
• Add Operations to the Class Model
• Iterate and refine the models
• After the first iteration, steps may occur in parallel
or out of order
• All models must be kept in synch as changes are made
Dynamic Modeling
• Prepare scenarios
• Identify events between objects
• Prepare an event trace for each scenario
• Build a state diagram
• Match events between objects to verify consistency
Dynamic Model Diagrams
Event-b
STATE-1 STATE-2
Event-a
Event- Event-e
c
STATE-3 Event-d result
OMT State Diagram - Example
Chess game
checkmate
Start White´s Black wins
turn
stalemate
black white
moves moves Draw
stalemate
Black´s
White wins
turn
checkmate
Guards, Activities and Actions
A-STATE [guard-1]
STATE-1
entry / entry-action action-Event / action
do: activity-A
event-1 / action-1 output-Event / output
... guarded-Event [guard-2]
exit / exit-action
STATE-2
Guards, Activities and Actions - Example
event-2
(Synchronization)
event-1 substate-3
split-event-0 substate-1 merged-event-3
event-2 merged-event-4
substate-2 substate-4
State Generalization: example
Transmission
push N
Neutral Reverse
push R
push N push F
downshift downshift
Returning to the FastData example
• Lets define a scenario for an office supply order processor: a successful order
• Alternatively we could describe a scenario for an unsuccessful order
• Assumptions
• We are not going to consider how the order form is transmitted to our system nor how
our receipt is transmitted back
• The employee object is responsible for validating the input to the system
A successful order
validated
create
create
add
repeat
validate item
validated
Event Trace, continued
retrieve cost
add order
create
(One Possible) State Transition Diagram
input
Employee Initialization
Created
received
Idle validated
Employee Order
Validated Created
create
return
receipt validated
• Class Modeling
• Dynamic Modeling
• Functional Modeling
• Add Operations to the Class Model
• Iterate and refine the models
• After the first iteration, steps may occur in parallel
or out of order
• All models must be kept in synch as changes are made
Functional Modeling
data-1 sink-data
Process-1 Process-2 Actor-2
source-data data-2
Actor-1 DataStore-1
Data Value Notation
data-1
composite
data-2
data-1
data-
1
composite data-1
data-1
data-
2
Control Flow in the DFD
coded
password Account
verify
password password balance
OK
amount
Customer update
cash
Hierarchical DFD
Employee Account
DB DB
response (receipt)
Data Flow Diagram: Office Supply example
Product Order
DB DB
response (receipt)
OMT Analysis and Design: Steps
• Class Modeling
• Dynamic Modeling
• Functional Modeling
• Add Operations to the Class Model
• Iterate and refine the models
• After the first iteration, steps may occur in parallel
or out of order
• All models must be kept in synch as changes are made
Add Operations to the Object Model
• From the Object Model:
• Reading/writing object attributes (e.g., get_width, get_height of Rectangle)
• From Events, State Actions, and Activities
in the Dynamic Model:
• Each event sent to an object => operation
(e.g., Vending machine: set_balance)
• Actions/activities may be operations
(e.g., Vending machine: do: test item and compute change)
• From Functions in the Functional Model:
• Each function in the DFD corresponds to an operation (e.g., bank example: subtract
withdrawal from Account)
Relation of the three models
Things
object model
Transformations
Interactions functional model
dynamic model
Relation of Dynamic Model
to Class Model
• Dynamic model provides a second dimension - time - to objects and
classes
• Dynamic model builds upon and is derived from object model
• states in dynamic model represent sets of attribute and link values in object
model
• events in dynamic model represent operations in object model
• Relation between organization
• inherent differences in objects are distinguished in object model as distinct
classes
• temporal differences in object attributes are distinguished in dynamic model
as distinct states
Relation of Functional Model
to Class and Dynamic Model
• Functional model describes the actions (what), the dynamic model
describes the timing (when), and the class model describes what
takes action (who)
• Functional model builds upon and is derived from class model
• processes in the functional model correspond to operations on objects
• The input streams of processes in the functional model identify objects that
are related by function
• data flows in the functional model correspond to objects or attribute values
in the class model
• Functional model may capture actions not part of any scenario
OMT: Four phases
• Object-oriented analysis
• builds a real-world model
• System design
• determines overall architecture of system
• Object design
• decides upon data structures and algorithms
• Implementation
• translates design into programming language
System Design
Presented By:
Satish Kumar Alaria
Department of CSE/IT
Subject: Software Engineering Lab
What is UML?
• Unified Modeling Language
– OMG Standard, Object Management Group
– Based on work from Booch, Rumbaugh, Jacobson
• UML is a modeling language to express and
design documents, software
– Particularly useful for OO design
– Not a process, but some have been proposed using
UML
– Independent of implementation language
Why use UML
• Open Standard, Graphical notation for
– Specifying, visualizing, constructing, and documenting software
systems
• Language can be used from general initial design to very
specific detailed design across the entire software
development lifecycle
• Increase understanding/communication of product to
customers and developers
• Support for diverse application areas
• Support for UML in many software packages today (e.g.
Rational, plugins for popular IDE’s like NetBeans, Eclipse)
• Based upon experience and needs of the user community
Brief History
• Inundated with methodologies in early 90’s
– Booch, Jacobson, Yourden, Rumbaugh
• Booch, Jacobson merged methods 1994
• Rumbaugh joined 1995
• 1997 UML 1.1 from OMG includes input from
others, e.g. Yourden
• UML v2.0 current version
History of UML
Systems, Models and Views
• A model is an abstraction describing a subset of a system
• A view depicts selected aspects of a model
• A notation is a set of graphical or textual rules for
depicting views
• Views and models of a single system may overlap each
other
Examples:
• System: Aircraft
• Models: Flight simulator, scale model
• Views: All blueprints, electrical wiring, fuel system
Systems, Models and Views
Flightsimulator
Blueprints
Aircraft
Model 2
View 2
View 1
System
View 3
Model 1
Electrical
Wiring
Scale Model
UML Models, Views, Diagrams
• UML is a multi-diagrammatic language
– Each diagram is a view into a model
• Diagram presented from the aspect of a particular stakeholder
• Provides a partial representation of the system
• Is semantically consistent with other views
– Example views
Models, Views, Diagrams
How Many Views?
• Views should to fit the context
– Not all systems require all views
– Single processor: drop deployment view
– Single process: drop process view
– Very small program: drop implementation view
• A system might need additional views
– Data view, security view, …
Basic Modeling Steps
• Use Cases
– Capture requirements
• Domain Model
– Capture process, key classes
• Design Model
– Capture details and behaviors of use cases and
domain objects
– Add classes that do the work and define the
architecture
UML Baseline
• Use Case Diagrams
• Class Diagrams
• Package Diagrams
• Interaction Diagrams
– Sequence
– Collaboration
• Activity Diagrams
• State Transition Diagrams
• Deployment Diagrams
Use Case Diagrams
• Used during requirements
elicitation to represent external
behavior
Anything missing?
Exit condition:
• Passenger has ticket.
Exceptional cases!
The <<extends>> Relationship
• <<extends>> relationships represent
exceptional or seldom invoked cases.
• The exceptional event flows are
Passenger factored out of the main event flow for
clarity.
• Use cases representing exceptional
flows can extend more than one use
PurchaseTicket case.
• The direction of a <<extends>>
<<extends>> relationship is to the extended use case
<<extends>>
<<extends>>
Cancel NoChange
The <<includes>>
Relationship
• <<includes>> relationship
represents behavior that is
Passenger
factored out of the use case.
• <<includes>> behavior is
factored out for reuse, not because
PurchaseMultiCard it is an exception.
PurchaseSingleTicket • The direction of a <<includes>>
<<includes>> relationship is to the using use
<<includes>> case (unlike <<extends>>
relationships).
CollectMoney
<<extends>> <<extends>>
NoChange Cancel
Use Cases are useful to…
• Determining requirements
– New use cases often generate new requirements as the
system is analyzed and the design takes shape.
• Communicating with clients
– Their notational simplicity makes use case diagrams a good
way for developers to communicate with clients.
• Generating test cases
– The collection of scenarios for a use case may suggest a
suite of test cases for those scenarios.
Use Case Diagrams: Summary
• Use case diagrams represent external behavior
• Use case diagrams are useful as an index into
the use cases
• Use case descriptions provide meat of model,
not the use case diagrams.
• All use cases need to be described for the
model to be useful.
Class Diagrams
• Gives an overview of a system by showing its
classes and the relationships among them.
– Class diagrams are static
– they display what interacts but not what happens
when they do interact
• Also shows attributes and operations of each
class
• Good way to describe the overall architecture
of system components
Class Diagram Perspectives
• We draw Class Diagrams under three
perspectives
– Conceptual
• Software independent
• Language independent
– Specification
• Focus on the interfaces of the software
– Implementation
• Focus on the implementation of the software
Classes – Not Just for Code
TariffSchedule
Table zone2price
Enumeration getZones()
Name Price getPrice(Zone)
TariffSchedule
zone2price Attributes Signature
getZones()
getPrice()
Operations TariffSchedule
Employee
-Name : string
+ID : long
#Salary : double
+getName() : string
+setName()
-calcInternalStuff(in x : byte, in y : decimal)
UML Class Notation
• Lines or arrows between classes indicate relationships
– Association
• A relationship between instances of two classes, where one class must know
about the other to do its work, e.g. client communicates to server
• indicated by a straight line or arrow
– Aggregation
• An association where one class belongs to a collection, e.g. instructor part of
Faculty
• Indicated by an empty diamond on the side of the collection
– Composition
• Strong form of Aggregation
• Lifetime control; components cannot exist without the aggregate
• Indicated by a solid diamond on the side of the collection
– Inheritance
• An inheritance link indicating one class a superclass relationship, e.g. bird is
part of mammal
• Indicated by triangle pointing to superclass
Binary Association
Binary Association: Both entities “Know About” each other
myB.service(); myA.doSomething();
Employee
Team
-Name : string
-members : Employee +ID : long
1 #Salary : double
-adfaf : bool
*
+getName() : string
+setName()
-calcInternalStuff(in x : byte, in y : decimal)
members[0] =
new Employee();
… Filled diamond on
delete members[0]; side of the Collection
Inheritance
Standard concept of inheritance
Base Class
Derived Class
Multiplicities Meaning
zero or one instance. The notation n . . m
0..1
indicates n to m instances.
no limit on the number of instances
0..* or *
(including none).
1 exactly one instance
1..* at least one instance
UML Class Example
Association Details
• Can assign names to the ends of the
association to give further information
Employee
Team -group
-Name : string
-members: Employee -individual +ID : long
1 #Salary : double
-adfaf : bool
*
+getName() : string
+setName()
-calcInternalStuff(in x : byte, in y : decimal)
Static vs. Dynamic Design
• Static design describes code structure and object
relations
– Class relations
– Objects at design time
– Doesn’t change
• Dynamic design shows communication between
objects
– Similarity to class relations
– Can follow sequences of events
– May change depending upon execution scenario
– Called Object Diagrams
Object Diagrams
• Shows instances of Class Diagrams and links
among them
– An object diagram is a snapshot of the objects in a
system
• At a point in time
• With a selected focus
– Interactions – Sequence diagram
– Message passing – Collaboration diagram
– Operation – Deployment diagram
Object Diagrams
• Format is
– Instance name : Class name
– Attributes and Values
– Example:
Objects and Links
DispatcherInterface
Notification IncidentManagement
More Package Examples
Interaction Diagrams
• Interaction diagrams are dynamic -- they
describe how objects collaborate.
• A Sequence Diagram:
– Indicates what messages are sent and when
– Time progresses from top to bottom
– Objects involved are listed left to right
– Messages are sent left to right between objects in
sequence
Sequence Diagram Format
Actor from
Use Case Objects
2
Activation 3
Shows Destruction of b
(and Construction)
Sequence Diagram : Timing
Slanted Lines show propagation delay of messages
Good for modeling real-time systems
• Ordering System
• May need multiple
diagrams from other
points of view
Activity Diagram Example
State Transition Diagrams
• Fancy version of a DFA
• Shows the possible states of the object and the
transitions that cause a change in state
– i.e. how incoming calls change the state
• Notation
– States are rounded rectangles
– Transitions are arrows from one state to another. Events or
conditions that trigger transitions are written beside the
arrows.
– Initial and Final States indicated by circles as in the
Activity Diagram
• Final state terminates the action; may have multiple final states
State Representation
• The set of properties and values describing the object
in a well defined instant are characterized by
– Name
– Activities (executed inside the state)
• Do/ activity
– Actions (executed at state entry or exit)
• Entry/ action
• Exit/ action
– Actions executed due to an event
• Event [Condition] / Action ^Send Event
Notation for States
Simple Transition Example
More Simple State Examples
State Transition Example
Validating PIN/SSN
State Charts – Local Variables
• State Diagrams can also store their own local
variables, do processing on them
• Library example counting books checked out
and returned
Borrow /
N = N+1
Is-Member Clean-Up
Return /
N=N-1
Component Diagrams
• Shows various components in a system and their
dependencies, interfaces
• Explains the structure of a system
• Usually a physical collection of classes
– Similar to a Package Diagram in that both are used to group
elements into logical structures
– With Component Diagrams all of the model elements are
private with a public interface whereas Package diagrams
only display public items.
Component Diagram Notation
• Components are shown as rectangles with two
tabs at the upper left