Avancier Copyright Avancier Limited 2012 Avancier Methods UML distilled – popular diagram types Including some Figures from the UML 2.4.1 standard (Know that UML is enormous It would take a week to learn all of it)
Avancier
Copyright Avancier Limited 2012
Avancier Methods UML distilled – popular diagram types
Including some Figures from the UML 2.4.1 standard
(Know that UML is enormous
It would take a week to learn all of it)
Avancier Structure diagrams – most popular
► Class diagram: a system's classes, with their attributes and interrelationships
► Deployment diagram: execution environments and artefacts deployed onto hardware.
► Component diagram: components and the dependencies among these components.
► Package diagram: logical groupings in a system and dependencies among groupings.
Copyright Avancier Limited 2012
Avancier Class diagram: Classes
A class (or type) is
► a specification for objects (or instances) that
► can be instantiated at run time to do some work.
A class specifies
► the data variables (or attributes) an object holds or maintains.
► the operations (or methods) an object can perform
Copyright Avancier Limited 2012
ClassName
Attribute:Type = initial value
operation (arg list):return type
ClassName
► Operation is a only a signature.
► Not a method body (the procedure that produces the return
type from the argument list)
Avancier
Copyright Avancier Limited
Class diagram
► What are the basic components of a software system?
► How are they related?
► Software architects decompose applications into classes (not
only data-entity-centric classes like the ones shown here).
Avancier
Copyright Avancier Limited 2012
Two kinds of relationship in UML
► An association
shows that two
objects can talk to
each other by
message passing.
► A generalisation-
specialisation
shows that a
subtype class
extends a super type
class by inheriting
operations from it.
Class A
Class B
1
1
Department
Employee
1
*
Order
Order Line
1
*
Dialogue Box
Control
1
*
Data Type <<superclass>>
Number <<subclass>>
Character <<subclass>>
Avancier Generalisation – Specialisation relations
Copyright Avancier Limited 2012
Avancier Class diagram: relationships
Aggregation Composition
Copyright Avancier Limited 2012
Association
Class A
Class B
1
1
Department
Employee
1
*
Class
Pupil
Team
Player
1
Order
Order Line
1
*
Dialogue Box
Control
1
*
Generalisation (class hierarchy)
You have to annotate w “disjoint”
to express mutual exclusion
Class <<superclass>>
Class <<subclass>>
Class <<subclass>>
1..30 11
1
Ape
Human
Avancier
Copyright Avancier Limited 2012
Interface
► An interface is a special kind of class,
and to be used, it requires a special kind
of relationship.
► An interface is an abstract super type;
this means it has operation signatures,
but not operation implementations, so it
cannot be instantiated as an object.
► This super type is connected by an
idealisation-realisation relationship to a
subtype which contains implementations
for the abstract operation signatures
■ This relationship is a subtype of
generalisation-specialisation, and
realisation is a subtype of inheritance.
Account
Current Account
Deposit Account
Avancier Required and provided interfaces
► UML 2.0 class diagrams brought new diagram elements, such
as ports, slots, provided and required interfaces.
Copyright Avancier Limited 2012
Avancier
Copyright Avancier Limited 2012
Two other kinds of relationship
► Subtle differences in the arrow and its head make a difference
Implementation (or realisation)
Class or Component
Interface
Dependency (usually reflects one or more invocations)
A B
Avancier
Copyright Avancier Limited 2012
Relations in UML
Relationship UML Meaning
Association End associated with End
Association Aggregation
Association Composition
Inheritance Specialisation Child is a specialisation of Parent. Child can do what Parent
can do.
Inheritance Realisation Child does what Parent offers
Dependency Source depends on Target, may be affected by a change to
target.
Data flow
Trigger
???
► The meanings of the lines
Avancier Class diagram: Ways to show a class
► Hiding or showing attributes and operations
Copyright Avancier Limited 2012
Avancier Deployment diagram:
► execution environments and artefacts deployed onto hardware.
Copyright Avancier Limited 2012
Avancier Stereotyped boxes and lines
Nodes computational units or processors,
and within them components or packages
Lines connections (communication paths) and
dependencies (as per package diagram)
Copyright Avancier Limited 2012
Processor A
Component 2
TCP/IP
Processor B
Component 1
Component 2
<<communication>>
Client PC
TCP/IP
{>50m/sec}
A “stereotyped” node
Avancier Component diagram:
► components and the dependencies among these components. ■ Components shown as boxes.
■ Interfaces shown as lollipops.
■ Dependencies shown in two ways.
Copyright Avancier Limited 2012
UML 2
Lollipop grabber
UML 1
Dependency arrow
Component Component
Component Component
Avancier
Copyright Avancier Limited 2012
Why dwell on component diagrams?
► Martin Fowler tends to dismiss UML component diagrams
(can't see how they differ from class diagrams).
► But I find them better for teaching architecture definition.
■ components are technology neutral - do not have to be OOPL
classes.
■ components usually represent physical deployable chunks
of software - not just logical abstractions.
■ the concepts of interfaces and dependencies on interfaces
are shown more graphically.
■ this session on component diagrams leads naturally to discussion
of methodologies - CBD and SOA.
Avancier Package diagram:
► logical groupings in a system and dependencies among groupings.
Copyright Avancier Limited 2012
Package Name Package Name
Package Name
Class 1 Class 2
Class 3
dependency
Avancier Behaviour diagrams – most popular
► Use case diagram: processes that actors of a system are involved in, and dependencies between use cases.
► Activity diagram: step-by-step flow of work - shows the overall flow of control.
► State machine diagram the states and state transitions of a process.
► Interaction diagram ■ Sequence diagram: a sequence of message-based interactions
between objects or components
■ Communication diagram: a sequence of message-based interactions between objects or components
Copyright Avancier Limited 2012
Avancier Use case diagram:
► processes that actors of a system are involved in…
Copyright Avancier Limited 2012
Avancier Use case diagram:
► processes that actors of a system are involved in...
Copyright Avancier Limited 2012
Avancier Use case diagram:
► processes that actors of a system are involved in,
► and dependencies between use cases.
Copyright Avancier Limited 2012
Sign on system
User
Log On
Some common
process
Force
Change Password
<<includes>>
<<extends>>
Change
Directory
Entry
Change
Password
<<includes>>
<<includes>>
Avancier Activity diagram:
► step-by-step flow of work
► shows the overall flow of control.
Copyright Avancier Limited 2012
Avancier Activity diagram:
► step-by-step flow of work
► shows the overall flow of
control.
Copyright Avancier Limited 2012
Assess
Incident
Contact
Manager
Sound
Alarm
Shut off
Machine
Leave
Building
[emergency]
[disaster]
* [for all machines]
[synchronisation condition]
Avancier Activity diagram:
► step-by-step flow of work
► shows the overall flow of control.
Copyright Avancier Limited 2012
Avancier Activity diagram:
► Swimlanes divide the behaviour between structural components
Copyright Avancier Limited 2012
Avancier Activity diagram:
Copyright Avancier Limited 2012
► Quadrant divides behaviour between structural components and
locations
Avancier Activity diagram:
► Interrupt event in interruptive activity region
Copyright Avancier Limited 2012
Avancier State machine diagram
► the states and state transitions of a process.
Copyright Avancier Limited 2012
Avancier State machine diagram
Similar to activity diagrams Nodes: states rather than steps Lines: transitions "decorated” to indicate the triggering method
call or condition
Copyright Avancier Limited 2012
Born
Voter
Dead
18th Birthday
Vote
Death
Birth
Logged On
Logged Off
Waiting
Authentication
Enter Id
Change P’word
Id match
Id mismatch
Log Off
Disconnection
Avancier State machine diagram
Copyright Avancier Limited 2012
Avancier
Interaction diagram Sequence diagram:
► a sequence of message-based interactions between objects or
components
Copyright Avancier Limited 2012
Avancier Two contrasting design patterns
► Chain
► Choreography
► Fork
► Orchestration
Copyright Avancier Limited 2012
Order
Closure
Order
Closure Order
Closure
Order
Closure
Discount
Enquiry
Order ItemCustomer Order ProductOrder Closure
Chain or
Staircase style
Order
Closure
Order
Closure
Order
Closure
Order
Closure
Discount
Enquiry
Order ItemCustomer Order ProductOrder Closure
Comb or
Flat style
Avancier
Copyright Avancier Limited 2012
Interaction diagram Sequence diagram:
Marriot Hotel Chain
MarriotNewark Hotel
bookRoom (dates): void
bookRoom (dates): void
*[for each day] isRoom:=free(): boolean
X
[isRoom]
Operation lifeline Activation bar
Object lifeline
Message
Object [of] Class
Iteration
Deletion
window User Interface
aBooking Booking
aNotice Notice
sequence
Object Instantiation
Avancier
Interaction diagram Sequence diagram:
► Sequence diagrams can
be broken up into
"interaction fragments",
which may be
represented in the same
or a separate diagram
*alt = if/else Upper part will be
executed if alt = true
alt = false
sd – named sequence diagram ref – reference to "interaction fragment" defined elsewhere loop – repeat interaction fragment alt – selection P ar – concurrent (parallel) regions seq – partial ordering (default) (aka "weak") strict – strict ordering assert – required (i.e. causal) opt – optional "exemplar" neg – "can’t happen" or a negative specification
Copyright Avancier Limited 2012
Avancier
Interaction diagram Sequence diagram:
► a sequence of message-based interactions between objects or components
Copyright Avancier Limited 2012
Avancier
Interaction diagram Communication diagram:
► a sequence of message-based interactions between objects or components
Copyright Avancier Limited 2012