SWT - Diagrammatics Lecture 4/4 - Diagramming in OO Software Development - partB 4-May-2000

Download Report

Transcript SWT - Diagrammatics Lecture 4/4 - Diagramming in OO Software Development - partB 4-May-2000

SWT - Diagrammatics
Lecture 4/4 - Diagramming in OO Software Development - partB
4-May-2000
Previous Lecture Review
–
–
–
–
–
–
OO Introduction,
OO Design Notations, Booch-OMT-UML
Objects, Messages / Control & Data Flow, Classes.
Class Attributes and Operations,
Visibility of Attributes and Operations,
Relationships :
– Association, Multiplicity, Aggregation,
– Dependency, Inheritance.
– Object Oriented Views
Overview
– Introduction to UML
– Goals, History - Timeline, External influences
– The 9 types of UML diagrams :
– Use Case, Class, Object, Sequence, Collaboration,
– Statechart, Activity, Component, Deployment
– Flow of data between views
– UML references
UML
• Unified Modelling Language UML
– Comprehensive syntax
– Language, Process and Tool independent.
• Four goals :
– To represent complete systems
– To establish explicit coupling between concepts and
executable code
– To take into account scaling factors
– To allow use by both humans and computers
UML Timeline
1995
1996
Unified
Method
0.8
Unified
Method
0.9
Jan
1997
Sep
1997
UML 1.0
UML1.1
Various OO
Methodologies
Booch’91
Booch’93
OMT-1
OMT-2
UML Partners
OOSE
External Influences
Origin
Booch
Embley
GOF
Harel
Jacobson
Meyer
Odell
OMT
Shlaer-Mellor
Wrifs-Brock
Element
Categories / Subsystems
Singleton classes / Composite objects
Frameworks / Patterns
Statecharts
Use Cases
Pre/Post conditions
Dynamic classification / Events
Associations
Object Lifecycles
Responsibilities / Collaborations
UML diagram types
User Requirements
1.Use Case
Static Structure
2.Class
3.Object
Interaction
4.Sequence
5.Collaboration
6.Statechart
7.Activity
Implementation
8.Component
9.Deployment
: system functions from a user’s perspective
: objects and their relationships
: classes and their relationships
: dynamic object interaction
: object and their links/interactions
: behaviour of a class that has states
: operation behaviour (as a set of actions)
: software components
: software on particular hardware platforms
1. Use case diagrams
• Use case diagrams :
– Describe the behaviour of a system from a user’s perspective.
– Depict relationships between the system and its environment.
– Allow the definition of the systems’ boundaries.
• A use case diagram can be seen as an instance of
interaction between “actors” and the system.
expresses understands
User
implements
Use case
verifies
designs
Programmer
Analyst
Tester
Architect
Use Case diagrams
• May contain any of the following relationships :
– Communicates :
triggers
– Uses :
Use Case A
Use Case B
<<uses>>
Use Case B
– Extends :
<<extends>>
Use Case A
Use Case B
A Use Case Diagram example
2. Class Diagrams
Abstract Class Name
Multiplicity : 1,0..1,*,M..N, N, M..*
Inheritance
Class name
+ Public Attribute
# Protected Attribute
- Private Attribute
+ Public Operation( )
# Protected Operation( )
- Private Operation( )
Association
Aggregation
Dependency
Class name
Class name
Class name
3. Object Diagrams
• An object/instance diagram represents a concrete
situation at a given time.
• It expresses both the static structure -found in class
diagrams- and behaviour.
• Object diagrams contains objects connected by links.
• Object Diagrams are mainly used to show a context of
interaction or to facilitate the understanding of a
complex data structure.
An Object Diagram example
myCar : Car
w1 : Wheel
w2 : Wheel
Car
=
1 1
Engine
1
4
Wheel
w3 : Wheel
myEngine : Engine
Composition with :
w4 : Wheel
Or containment :
myCar : Car
myEngine : Engine
4. Sequence Diagrams
• Sequence diagrams focus on displaying the interaction
between objects, without representing explicitly the
context of interaction and the object’s state.
• Depicting the chronology of the message broadcast,
they are useful in all stages of OO modelling.
: Caller
: Phone
: Recipient
picks up
dial tone
dial
ring
picks up
says hello...
A Sequence Diagram example
5. Collaboration Diagrams
• Collaboration Diagrams express both the context of a
group of objects and the interaction between these
objects.
• Can be considered to be an extension of Object
diagrams, adding notation to represent object
interaction.
• Messages are depicted using lines decorated with an
arrow that points towards the recipient.
• To indicate the sending order, messages are explicitly
numbered.
A Collaboration Diagram example
3 : *get
2 : get details
1 : Enter item
description
stocktem: Item
myitem: Item
4 : getProperties
myOrder: Order
op: OrderProperties
6. Statechart Diagrams
• A state machine can be used to describe formally the
behaviour of objects in terms of states and events.
• Statecharts represent with :
intermediate
–
–
–
–
–
initial
states : the state of an object
transitions : the passing from one state to another
events : the occurrence of a given situation
guards : conditions for the triggering of events
actions and activities : operations of an object
final
event
event [cond]
Two StateChart diagrams
byte read
URL delay
washing
rinsing
drying
H
prefix read
opened door
wait for length
closed door
length read
read data
byte read [Count<Length]
Suffix read [Count==Length]
Opened door
7. Activity Diagrams
• Activity diagrams are :
– a variant of statechart diagrams, organised according to actions.
– targeted towards representing the internal behaviour of a
method, a mechanism or a use case.
•
•
•
•
An activity is represented by a round rectangle :
Decisions are represented using a diamond :
Synchronisation bars are used for synchronisation
Swimlanes are used to split the activity diagram in regions.
An Activity Diagram example
Get temperature
[ too cold ]
Heat up
[ too hot ]
Cool down
Switch off heating
Open windows
8. Component Diagrams
• Component diagrams depict software components and
their relationships within the implementation
environment.
• Components can be all kind of software elements : files,
libraries, databases etc.
Body
• Components contain two parts :
Specification
• A dependency relationship between components
A
usually represent compilation dependencies.
B
• Components may contain processes using
containment and can be grouped in subsystem
components.
A Component Diagram example
Order
Processing
System
UI
Data
Processor
Database
Data
Manager
External
System
9. Deployment Diagrams
• Deployment diagrams are used to illustrate the physical
layout of the various hardware components that are
needed for a system to operate.
• Hardware resources are represented by a cube : DB
Server
• Lines annotated with multiplicity information are used to
connect cubes.
B
A
0..1
A Deployment Diagram example
CMServers
<zeus>
CMclientJFC
CMclientAWT
CMclientCMD
Naming
Server
<robin>
CMServers
<robin>
Flow of data between views
Interaction Model
classes
interactions
operations
Use Case Model
Object Model
Classes & Attributes
events
classes
State Model
states
operations
Business Model -> Logical Model -> Component Model -> Deployment Model
UML references
UML at rational :
http://www.rational.com/uml/
List of tools supporting UML diagrams :
http://plg.uwaterloo.ca/~migod/uml.html
Cetus page on UML :
http://www.cetus-links.org/oo_uml.html
The end of diagrammatics course