You are on page 1of 66

UsingUML,Patterns,andJava

ObjectOrientedSoftwareEngineering

Chapter2,
ModelingwithUML

Overview:modelingwithUML

Whatismodeling?
WhatisUML?
Usecasediagrams
Classdiagrams

Nextlecture
Sequencediagrams
Activitydiagrams

BerndBruegge&AllenH.Dutoit

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

Whatismodeling?

Modelingconsistsofbuildinganabstractionofreality.
Abstractionsaresimplificationsbecause:
Theyignoreirrelevantdetailsand
Theyonlyrepresenttherelevantdetails.

Whatisrelevantorirrelevantdependsonthepurposeofthe
model.

BerndBruegge&AllenH.Dutoit

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

Example:streetmap

BerndBruegge&AllenH.Dutoit

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

Whymodelsoftware?
Whymodelsoftware?

Softwareisgettingincreasinglymorecomplex
WindowsXP>40miolinesofcode
Asingleprogrammercannotmanagethisamountofcodeinits
entirety.

Codeisnoteasilyunderstandablebydeveloperswhodidnot
writeit
Weneedsimplerrepresentationsforcomplexsystems
Modelingisameanfordealingwithcomplexity

BerndBruegge&AllenH.Dutoit

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

Systems,ModelsandViews

Amodelisanabstractiondescribingasubsetofasystem
Aviewdepictsselectedaspectsofamodel
Anotationisasetofgraphicalortextualrulesfordepictingviews
Viewsandmodelsofasinglesystemmayoverlapeachother

Examples:
System:Aircraft
Models:Flightsimulator,scalemodel
Views:Allblueprints,electricalwiring,fuelsystem

BerndBruegge&AllenH.Dutoit

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

Systems,ModelsandViews
Blueprints

Flightsimulator

Aircraft
Model2
System

View2

View1

View3
Model1

Scale Model

BerndBruegge&AllenH.Dutoit

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

Electrical
Wiring

Models,ViewsandSystems(UML)

System

Model

Describedby

View

Depictedby

Airplane:System

ScaleModel:Model

Blueprints:View
BerndBruegge&AllenH.Dutoit

FlightSimulator:Model

FuelSystem:View

ElectricalWiring:View

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

ConceptsandPhenomena
Phenomenon
Anobjectintheworldofadomainasyouperceiveit
Example:Thelectureyouareattending
Example:Myblackwatch

Concept
Describesthepropertiesofphenomenathatarecommon.
Example:Lecturesonsoftwareengineering
Example:Blackwatches

Conceptisa3tuple:
Name(Todistinguishitfromotherconcepts)
Purpose(Propertiesthatdetermineifaphenomenonisamember
ofaconcept)
Members(Thesetofphenomenawhicharepartoftheconcept)

BerndBruegge&AllenH.Dutoit

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

Conceptsandphenomena
Name

Clock

Purpose

Members

Adevicethat
measurestime.

Abstraction
Classificationofphenomenaintoconcepts

Modeling
Developmentofabstractionstoanswerspecificquestionsaboutasetof
phenomenawhileignoringirrelevantdetails.
BerndBruegge&AllenH.Dutoit

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

10

Conceptsinsoftware:TypeandInstance

Type:
Anabstractioninthecontextofprogramminglanguages
Name:int,Purpose:integralnumber,Members:0,1,1,2,
2,...

Instance:
Memberofaspecifictype

Thetypeofavariablerepresentsallpossibleinstancesthe
variablecantake

Thefollowingrelationshipsaresimilar:
type<>instance
concept<>phenomenon
BerndBruegge&AllenH.Dutoit

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

11

AbstractDataTypes&Classes

Abstractdatatype
Specialtypewhoseimplementationishidden
fromtherestofthesystem.

Class:
Anabstractioninthecontextofobject
orientedlanguages

Likeanabstractdatatype,aclass
encapsulatesbothstate(variables)and
behavior(methods)
ClassVector

Unlikeabstractdatatypes,classescanbe
definedintermsofotherclassesusing
inheritance

BerndBruegge&AllenH.Dutoit

Watch
time
date
SetDate(d)

CalculatorWatch
calculatorState
EnterCalcMode()
InputNumber(n)

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

12

ApplicationandSolutionDomain

ApplicationDomain(RequirementsAnalysis):
Theenvironmentinwhichthesystemisoperating

SolutionDomain(SystemDesign,ObjectDesign):
Theavailabletechnologiestobuildthesystem

BerndBruegge&AllenH.Dutoit

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

13

Objectorientedmodeling

Application Domain
Application Domain Model

UML Package

TrafficControl
Aircraft

SummaryDisplay

TrafficController

FlightPlan

BerndBruegge&AllenH.Dutoit

Solution Domain
System Model

Airport

MapDisplay

FlightPlanDatabase
TrafficControl

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

14

WhatisUML?

UML(UnifiedModelingLanguage)
Anemergingstandardformodelingobjectorientedsoftware.
Resultedfromtheconvergenceofnotationsfromthreeleading
objectorientedmethods:

OMT(JamesRumbaugh)
OOSE(IvarJacobson)
Booch(GradyBooch)

Reference:TheUnifiedModelingLanguageUserGuide,
AddisonWesley,1999.
SupportedbyseveralCASEtools
RationalROSE
TogetherJ

BerndBruegge&AllenH.Dutoit

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

15

UML:FirstPass

Youcanmodel80%ofmostproblemsbyusingabout20%
UML
Weteachyouthose20%

BerndBruegge&AllenH.Dutoit

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

16

UMLFirstPass

UsecaseDiagrams
Describethefunctionalbehaviorofthesystemasseenbytheuser.

Classdiagrams
Describethestaticstructureofthesystem:Objects,Attributes,
Associations

Sequencediagrams
Describethedynamicbehaviorbetweenactorsandthesystemand
betweenobjectsofthesystem

Statechartdiagrams
Describethedynamicbehaviorofanindividualobject(essentiallya
finitestateautomaton)

ActivityDiagrams
Modelthedynamicbehaviorofasystem,inparticulartheworkflow
(essentiallyaflowchart)
BerndBruegge&AllenH.Dutoit

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

17

UMLfirstpass:Usecasediagrams
Use case

Package
Watch

Actor
ReadTime

WatchUser

SetTime

WatchRepairPerson

ChangeBattery

Use case diagrams represent the functionality of the system


from users point of view
BerndBruegge&AllenH.Dutoit

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

18

UMLfirstpass:Classdiagrams
Class diagrams represent the structure of the system
Association

Class

Multiplicity

Watch
1

2
PushButton
state
push()
release()

Attribute

1
2

1
LCDDisplay
blinkIdx
blinkSeconds(
)
blinkMinutes(
)
blinkHours()
stopBlinking(
)
referesh()

Battery
load

1
Time
now

Operations

BerndBruegge&AllenH.Dutoit

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

19

UMLfirstpass:Sequencediagram
Actor
:WatchUser

Message

Object

:Watch

:LCDDisplay

pressButton1()

blinkHours()

pressButton1()

blinkMinutes()

pressButton2()

:Time

incrementMinutes()
refresh()

pressButtons1And2()

commitNewTime()
stopBlinking()

Activation

Lifeline

Sequence diagrams represent the behavior as interactions


BerndBruegge&AllenH.Dutoit

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

20

UMLfirstpass:Statechartdiagramsforobjects
withinterestingdynamicbehavior

Event

Initial state

State

[button2Pressed]

[button1&2Pressed]
BlinkHours

Transition

IncrementHrs

[button1Pressed]

[button2Pressed]

[button1&2Pressed]
BlinkMinutes

IncrementMin.

[button1Pressed]
[button2Pressed]

[button1&2Pressed]
BlinkSeconds

IncrementSec.

Final state

StopBlinking

Represent behavior as states and transitions

BerndBruegge&AllenH.Dutoit

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

21

OtherUMLNotations
UMLprovideothernotationsthatwewillbeintroducedin
subsequentlectures,asneeded.

Implementationdiagrams
Componentdiagrams
Deploymentdiagrams
IntroducedinlectureonSystemDesign

Objectconstraintlanguage
IntroducedinlectureonObjectDesign

BerndBruegge&AllenH.Dutoit

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

22

UMLCoreConventions

Rectanglesareclassesorinstances
Ovalsarefunctionsorusecases
Instancesaredenotedwithanunderlinednames
myWatch:SimpleWatch
Joe:Firefighter

Typesaredenotedwithnonunderlinednames
SimpleWatch
Firefighter

Diagramsaregraphs
Nodesareentities
Arcsarerelationshipsbetweenentities

BerndBruegge&AllenH.Dutoit

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

23

UseCaseDiagrams

Usedduringrequirements
elicitationtorepresentexternal
behavior

Actorsrepresentroles,thatis,a
typeofuserofthesystem
Passenger
Usecasesrepresentasequenceof
interactionforatypeof
functionality
Theusecasemodelisthesetof
allusecases.Itisacomplete
descriptionofthefunctionalityof
PurchaseTicket thesystemanditsenvironment

BerndBruegge&AllenH.Dutoit

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

24

Actors

Anactormodelsanexternalentitywhich
communicateswiththesystem:
User
Externalsystem
Physicalenvironment

Passenger

Anactorhasauniquenameandanoptional
description.
Examples:
Passenger:Apersoninthetrain
GPSsatellite:ProvidesthesystemwithGPS
coordinates

BerndBruegge&AllenH.Dutoit

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

25

UseCase
Ausecaserepresentsaclassof
functionalityprovidedbythesystemas
aneventflow.
Ausecaseconsistsof:
PurchaseTicket Uniquename
Participatingactors
Entryconditions
Flowofevents
Exitconditions
Specialrequirements
BerndBruegge&AllenH.Dutoit

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

26

UseCaseDiagram:Example
Name:Purchaseticket
Participatingactor:Passenger
Entrycondition:
Passengerstandinginfrontof
ticketdistributor.
Passengerhassufficientmoney
topurchaseticket.
Exitcondition:
Passengerhasticket.

Eventflow:
1.Passengerselectsthenumberof
zonestobetraveled.
2.Distributordisplaystheamount
due.
3.Passengerinsertsmoney,ofat
leasttheamountdue.
4.Distributorreturnschange.
5.Distributorissuesticket.

Anything missing?
Exceptional cases!

BerndBruegge&AllenH.Dutoit

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

27

The<<extends>>Relationship

Passenger

PurchaseTicket

<<extends>>

<<extends>>relationships

representexceptionalorseldom
invokedcases.
Theexceptionaleventflowsare
factoredoutofthemainevent
flowforclarity.
Usecasesrepresentingexceptional
flowscanextendmorethanone
usecase.
Thedirectionofa<<extends>>
relationshipistotheextendeduse
case

<<extends>>
<<extends>>

OutOfOrder

<<extends>>

Cancel
BerndBruegge&AllenH.Dutoit

TimeOut

NoChange
ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

28

The<<includes>>Relationship

Passenger

PurchaseMultiCard

PurchaseSingleTicket
<<includes>>
<<includes>>

<<extends>>

CollectMoney

NoChange
BerndBruegge&AllenH.Dutoit

<<includes>>relationship

representsbehaviorthatisfactored
outoftheusecase.
<<includes>>behavioris
factoredoutforreuse,notbecause
itisanexception.
Thedirectionofa<<includes>>
relationshipistotheusinguse
case(unlike<<extends>>
relationships).

<<extends>>

Cancel
ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

29

UseCaseDiagrams:Summary

Usecasediagramsrepresentexternalbehavior
Usecasediagramsareusefulasanindexintotheusecases
Usecasedescriptionsprovidemeatofmodel,nottheusecase
diagrams.
Allusecasesneedtobedescribedforthemodeltobeuseful.

BerndBruegge&AllenH.Dutoit

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

30

ClassDiagrams

TarifSchedule
EnumerationgetZones()
PricegetPrice(Zone)

Trip
zone:Zone
Price:Price

Classdiagramsrepresentthestructureofthesystem.
Used
duringrequirementsanalysistomodelproblemdomainconcepts
duringsystemdesigntomodelsubsystemsandinterfaces
duringobjectdesigntomodelclasses.

BerndBruegge&AllenH.Dutoit

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

31

Classes

Name
TarifSchedule
zone2price
getZones()
getPrice()

Attributes
Operations

TarifSchedule
Tablezone2price
EnumerationgetZones()
PricegetPrice(Zone)

Signature
TarifSchedule

Aclassrepresentaconcept
Aclassencapsulatesstate(attributes)andbehavior(operations).
Eachattributehasatype.
Eachoperationhasasignature.
Theclassnameistheonlymandatoryinformation.
BerndBruegge&AllenH.Dutoit

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

32

Instances
tarif_1974:TarifSchedule
zone2price={
{1,.20},
{2,.40},
{3,.60}}

Aninstancerepresentsaphenomenon.
Thenameofaninstanceisunderlinedandcancontaintheclassofthe
instance.
Theattributesarerepresentedwiththeirvalues.

BerndBruegge&AllenH.Dutoit

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

33

ActorvsInstances

Whatisthedifferencebetweenanactor,aclassandan
instance?
Actor:
Anentityoutsidethesystemtobemodeled,interactingwiththe
system(Passenger)

Class:
Anabstractionmodelinganentityintheproblemdomain,mustbe
modeledinsidethesystem(User)

Object:
Aspecificinstanceofaclass(Joe,thepassengerwhoispurchasing
aticketfromtheticketdistributor).

BerndBruegge&AllenH.Dutoit

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

34

Associations

TarifSchedule

TripLeg

EnumerationgetZones()
PricegetPrice(Zone)

Price
Zone

Associationsdenoterelationshipsbetweenclasses.
Themultiplicityofanassociationenddenoteshowmanyobjectsthesource
objectcanlegitimatelyreference.

BerndBruegge&AllenH.Dutoit

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

35

1to1and1tomanyAssociations
Has-capital

Country
name:String

City
name:String

Onetooneassociation
Polygon

Point
x: Integer
y: Integer

draw()

Onetomanyassociation
BerndBruegge&AllenH.Dutoit

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

36

ManytoManyAssociations

StockExchange

Lists

Company
tickerSymbol

StockExchange

BerndBruegge&AllenH.Dutoit

Lists

tickerSymbol

SX_ID

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

Company

37

FromProblemStatementToObjectModel

ProblemStatement:Astockexchangelistsmanycompanies.Each
companyisuniquelyidentifiedbyatickersymbol
Class Diagram:

StockExchange *

BerndBruegge&AllenH.Dutoit

Lists

Company
tickerSymbol

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

38

FromProblemStatementtoCode
ProblemStatement :Astockexchangelistsmanycompanies.
EachcompanyisidentifiedbyatickerSymbol
Class Diagram:
StockExchange

Java Code

Lists

Company
tickerSymbol

publicclassStockExchange
{
privateVectorm_Company=newVector();
};
publicclassCompany
{
publicintm_tickerSymbol;
privateVectorm_StockExchange=newVector();
};

BerndBruegge&AllenH.Dutoit

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

39

Aggregation

Anaggregationisaspecialcaseofassociationdenotingaconsistsof
hierarchy.
Theaggregateistheparentclass,thecomponentsarethechildrenclass.
Exhaust system

Exhaust system

0..2

1
Muffler

Tailpipe

diameter

diameter

0..2

1
Muffler

Tailpipe

diameter

diameter

Asoliddiamonddenotescomposition,astrongformofaggregationwhere
componentscannotexistwithouttheaggregate.(BillofMaterial)
TicketMachine

3
ZoneButton
BerndBruegge&AllenH.Dutoit

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

40

Qualifiers
Without qualification
Directory

File
filename

With qualification
Directory

filename

01

File

Qualifierscanbeusedtoreducethemultiplicityofan
association.

BerndBruegge&AllenH.Dutoit

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

41

Inheritance

Button

CancelButton

ZoneButton

Thechildrenclassesinherittheattributesandoperationsofthe
parentclass.
Inheritancesimplifiesthemodelbyeliminatingredundancy.

BerndBruegge&AllenH.Dutoit

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

42

ObjectModelinginPractice:ClassIdentification
Foo
Betrag
CustomerId
Deposit()
Withdraw()
GetBalance()

Class Identification: Name of Class, Attributes and Methods

BerndBruegge&AllenH.Dutoit

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

43

ObjectModelinginPractice:
EncourageBrainstorming
Foo

Dada
Betrag

Betrag

CustomerId

CustomerId

Deposit()
Withdraw()
GetBalance()

Deposit()
Withdraw()
GetBalance()

Account
Betrag
CustomerId

Naming is important!
Is Foo the right name?

BerndBruegge&AllenH.Dutoit

Deposit()
Withdraw()
GetBalance()

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

44

ObjectModelinginPracticectd
Account
Betrag
Bank
Name

AccountId
CustomerId
Deposit()
Withdraw()
GetBalance()

Customer
Name
CustomerId

1) Find New Objects


2) Iterate on Names, Attributes and Methods

BerndBruegge&AllenH.Dutoit

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

45

ObjectModelinginPractice:ABankingSystem
Account
Betrag
AccountId
CustomerId
AccountId

Bank

Has

Deposit()
Withdraw()
GetBalance()

Name

Customer
Name
CustomerId

1) Find New Objects


2) Iterate on Names, Attributes and Methods
3) Find Associations between Objects
4) Label the assocations
5) Determine the multiplicity of the assocations
BerndBruegge&AllenH.Dutoit

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

46

PracticeObjectModeling:Iterate,Categorize!
Account

Bank

Name

Amount
AccountId
CustomerId
AccountId

Customer
Has

Deposit()
Withdraw()
GetBalance()

Savings
Account

Withdraw()
BerndBruegge&AllenH.Dutoit

Name

CustomerId()

Checking
Account

Mortgage
Account

Withdraw()

Withdraw()

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

47

Packages

ApackageisaUMLmechanismfororganizingelementsinto
groups(usuallynotanapplicationdomainconcept)
Packagesarethebasicgroupingconstructwithwhichyoumay
organizeUMLmodelstoincreasetheirreadability.
DispatcherInterface

Notification

IncidentManagement

Acomplexsystemcanbedecomposedintosubsystems,where
eachsubsystemismodeledasapackage

BerndBruegge&AllenH.Dutoit

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

48

UMLsequencediagrams

Passenger

Usedduringrequirementsanalysis
Torefineusecasedescriptions
tofindadditionalobjects
(participatingobjects)

TicketMachine

selectZone()

Usedduringsystemdesign
torefinesubsysteminterfaces

insertCoins()

pickupChange()

pickUpTicket()

BerndBruegge&AllenH.Dutoit

Classesarerepresentedby
columns
Messagesarerepresentedby
arrows
Activationsarerepresentedby
narrowrectangles
Lifelinesarerepresentedby
dashedlines

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

49

Nestedmessages

Passenger

ZoneButton

selectZone()

TarifSchedule

Display

lookupPrice(selection)
price

Dataflow

displayPrice(price)

to be continued...

Thesourceofanarrowindicatestheactivationwhichsentthemessage
Anactivationisaslongasallnestedactivations
Horizontaldashedarrowsindicatedataflow
Verticaldashedlinesindicatelifelines
BerndBruegge&AllenH.Dutoit

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

50

Iteration&condition
continued from previous slide...
Passenger

ChangeProcessor

*insertChange(coin)
Iteration
Condition

CoinIdentifier

Display

CoinDrop

lookupCoin(coin)
price
displayPrice(owedAmount)

[owedAmount<0]returnChange(owedAmount)

to be continued...

Iterationisdenotedbya*precedingthemessagename
Conditionisdenotedbybooleanexpressionin[]beforethemessage
name

BerndBruegge&AllenH.Dutoit

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

51

Creationanddestruction
continued from previous slide...
Passenger

ChangeProcessor

Creation

createTicket(selection)
Ticket
print()
free()

Destruction

Creationisdenotedbyamessagearrowpointingtotheobject.
DestructionisdenotedbyanXmarkattheendofthedestructionactivation.
Ingarbagecollectionenvironments,destructioncanbeusedtodenotethe
endoftheusefullifeofanobject.
BerndBruegge&AllenH.Dutoit

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

52

SequenceDiagramSummary

UMLsequencediagramrepresentbehaviorintermsof
interactions.
Usefultofindmissingobjects.
Timeconsumingtobuildbutworththeinvestment.
Complementtheclassdiagrams(whichrepresentstructure).

BerndBruegge&AllenH.Dutoit

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

53

StateChartDiagrams
State

Initial state

Event

[button2Pressed]

[button1&2Pressed]
BlinkHours

Transition

IncrementHrs

[button1Pressed]

[button2Pressed]

[button1&2Pressed]
BlinkMinutes

IncrementMin.

[button1Pressed]
[button2Pressed]

[button1&2Pressed]
BlinkSeconds

IncrementSec.

Final state

StopBlinking

Represent behavior as states and transitions

BerndBruegge&AllenH.Dutoit

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

54

ActivityDiagrams

Anactivitydiagramshowsflowcontrolwithinasystem
Handle
Incident

Document
Incident

Archive
Incident

Anactivitydiagramisaspecialcaseofastatechartdiagramin
whichstatesareactivities(functions)
Twotypesofstates:
Actionstate:

Cannotbedecomposedanyfurther
Happensinstantaneouslywithrespecttothelevelofabstractionused
inthemodel

Activitystate:

Canbedecomposedfurther
Theactivityismodeledbyanotheractivitydiagram

BerndBruegge&AllenH.Dutoit

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

55

StatechartDiagramvs.ActivityDiagram
Statechart Diagram for Incident (similar to Mealy Automaton)
(State: Attribute or Collection of Attributes of object of type Incident)
Event causes
State transition
Active

Inactive
Incident
Handled

Closed
Incident
Documented

Archived
Incident
Archived

Activity Diagram for Incident (similar to Moore


(State: Operation or Collection of Operations)
Handle
Incident

Document
Incident

Completion of activity
causes state transition
BerndBruegge&AllenH.Dutoit

Archive
Incident

Triggerless
Transition

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

56

ActivityDiagram:ModelingDecisions

[lowPriority]
Open
Incident

Allocate
Resources
[fire&highPriority]

[notfire&highPriority]
Notify
FireChief
Notify
PoliceChief

BerndBruegge&AllenH.Dutoit

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

57

ActivityDiagrams:ModelingConcurrency

Synchronizationofmultipleactivities
Splittingtheflowofcontrolintomultiplethreads

Splitting

Open
Incident

Allocate
Resources

Coordinate
Resources

Synchronization

Archive
Incident

Document
Incident

BerndBruegge&AllenH.Dutoit

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

58

ActivityDiagrams:Swimlanes

Actionsmaybegroupedintoswimlanestodenotetheobjector
subsystemthatimplementstheactions.
Allocate
Resources

Open
Incident

Coordinate
Resources

Dispatcher

Archive
Incident
FieldOfficer

Document
Incident

BerndBruegge&AllenH.Dutoit

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

59

Whatshouldbedonefirst?CodingorModeling?

Italldepends.

ForwardEngineering:
Creationofcodefromamodel
Greenfieldprojects

ReverseEngineering:
Creationofamodelfromcode
Interfaceorreengineeringprojects

RoundtripEngineering:
Moveconstantlybetweenforwardandreverseengineering
Usefulwhenrequirements,technologyandschedulearechanging
frequently
BerndBruegge&AllenH.Dutoit

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

60

UMLSummary

UMLprovidesawidevarietyofnotationsforrepresenting
manyaspectsofsoftwaredevelopment
Powerful,butcomplexlanguage
Canbemisusedtogenerateunreadablemodels
Canbemisunderstoodwhenusingtoomanyexoticfeatures

Fornowweconcentrateonafewnotations:
Functionalmodel:Usecasediagram
Objectmodel:classdiagram
Dynamicmodel:sequencediagrams,statechartandactivity
diagrams

BerndBruegge&AllenH.Dutoit

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

61

AdditionalSlides

BerndBruegge&AllenH.Dutoit

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

62

ModelsforPlatosandAristotlesViewsofReality
Plato

Aristotle

Materialrealityisasecondclass
subordinatetypeofreality.
Thefirstclasstypeisaform
Formsliebehindeverythingorin
theworld.Formscanbeabstract
nounslikebeautyormammal
orconcretenounsliketreeor
horse.
Thereisanimportantdifference
betweentheworldofformsand
particulars.Formsarenonmaterial,
particularsarematerial.Formsare
permanentandchangeless.
Particularsarechanging.
Formscanbeacquired
intellectuallythroughadialectic
processthatmovestowardthe
highestunderstandingofreality
throughtheinteractionofquestions
andanswers.

AristotleacceptedtherealityofFormsas
nonmaterialentities.
However,hecouldnotacceptPlatosidea,that
theseFormswerenotreal.
Insteadoftwoseparateworlds,oneforForms
andoneforParticulars,Aristotlehadonlyone
world,aworldofparticularthings.
ParticularthingsaccordingtoAristotlehavea
certainpermanceaboutthem,evenwhilethey
aresubjecttochange:Atreechangescolors
withoutceasingtobeatree.Ahorsegrowsin
sizewithoutceasingtobeahorse.
Whatistherootofthispermancence?Itisthe
thingsinternalform,whichmindsdetect,when
theypenetratebeyondthethingschanging
attributes.SoforAristotle,realityisthusmade
upofparticularthingsthatareeachcomposedof
formantdnmatter..

UsingUML,wecanillustratePlatonsandAristotlesviewpointsveryeasily
andseetheirdifferencesaswell
BerndBruegge&AllenH.Dutoit

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

63

ModelforPlatosViewofReality
Plato

Materialrealityisasecondclass
subordinatetypeofreality.
Thefirstclasstypeisaform
Formsliebehindeverythingorin
theworld.Formscanbeabstract
nounslikebeautyormammal
orconcretenounsliketreeor
horse.
Thereisanimportantdifference
betweentheworldofformsand
particulars.Formsarenonmaterial,
particularsarematerial.Formsare
permanentandchangeless.
Particularsarechanging.
Formscanbeacquired
intellectuallythroughadialectic
processthatmovestowardthe
highestunderstandingofreality
throughtheinteractionof
questionsandanswers.
BerndBruegge&AllenH.Dutoit

Reality

Thing

Particular

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

Form

64

ModelAristotlesViewsofReality
Aristotle

AristotleacceptedtherealityofForms
asnonmaterialentities.
However,hecouldnotacceptPlatos
idea,thattheseFormswerenotreal.
Insteadoftwoseparateworlds,onefor
FormsandoneforParticulars,
Aristotlehadonlyoneworld,aworld
ofparticularthings.
ParticularthingsaccordingtoAristotle
haveacertainpermanceaboutthem,
evenwhiletheyaresubjecttochange:
Atreechangescolorswithoutceasing
tobeatree.Ahorsegrowsinsize
withoutceasingtobeahorse.
Whatistherootofthispermancence?
Itisthethingsinternalform,which
mindsdetect,whentheypenetrate
beyondthethingschangingattributes.
SoforAristotle,realityisthusmadeup
ofparticularthingsthatareeach
composedofformantdnmatter. .

BerndBruegge&AllenH.Dutoit

Reality

*
Substance

Form

ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

Matter

65

ComparisonofPlatosandAristotlesViews
Aristotle

Plato

Reality

Reality

Substance

Thing

Form
Particular
BerndBruegge&AllenH.Dutoit

Matter

Form
ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava

66

You might also like