UML Diagrams, examples, descriptions and tutorials

snsdeepak 111 views 76 slides Feb 19, 2024
Slide 1
Slide 1 of 76
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40
Slide 41
41
Slide 42
42
Slide 43
43
Slide 44
44
Slide 45
45
Slide 46
46
Slide 47
47
Slide 48
48
Slide 49
49
Slide 50
50
Slide 51
51
Slide 52
52
Slide 53
53
Slide 54
54
Slide 55
55
Slide 56
56
Slide 57
57
Slide 58
58
Slide 59
59
Slide 60
60
Slide 61
61
Slide 62
62
Slide 63
63
Slide 64
64
Slide 65
65
Slide 66
66
Slide 67
67
Slide 68
68
Slide 69
69
Slide 70
70
Slide 71
71
Slide 72
72
Slide 73
73
Slide 74
74
Slide 75
75
Slide 76
76

About This Presentation

UML Diagrams and its types along with examples.


Slide Content

1
UMLisamodellinglanguageusedforcreating
models.
Notasystemdesignordevelopmentmethodology.
Usedtodocumentresultofobject-orientedanalysis
anddesign.
Independentofanyspecificdesignmethodology
OBJECTMODELLING USINGUML

OBJECT MODELLING USING UML
Providessetofnotations(e.g.rectangles,lines
etc.)tocreateavisualmodelofthesystem.
UMLhasitsownsyntaxandsemantics.
2

3
Origin
Inlate1980sandearly1990sdifferent
softwaredevelopmenthouseswereusing
differentnotationstodocumentobject
orienteddesigns.
Developedinearly1990stostandardizethe
largenumberofobject-orientedmodelling
notations
UNIFIEDMODELLING LANGUAGE
(UML)

4
UMLwasdevelopedtostandardizethelarge
numberofobject-orientedmodelingnotations
thatexistedandwereusedextensivelyinthe
early1990s.
BasedPrincipallyon
OMT[Rumbaugh1991]
Booch’smethodology[Booch1991]
OOSE[Jacobson1992]
Odell’smethodology[Odell1992]
ShlaerandMellor[Shlaer1992]
UML

5
UML
UML
Booch
Methodology
OOSE
OMT
Different object modelling techniques in UML

6
AsaStandard
AdoptedbyObjectManagementGroup
(OMG)in1997
OMGanassociationofindustries
Promoteextensivesetofnotationsand
techniques
Usedoutsidesoftwaredevelopment,
examplecarmanufacturing
UML

7
Requiredtocaptureonlyimportantaspects
UMLagraphicalmodellingtool,easyto
understandandconstruct
Helpsinmanagingcomplexity
WHY UML IS REQUIRED?

8
ConstructNinediagramstocapturefive
differentviewsofasystem
Providedifferentperspectivesofthe
softwaresystem
Diagramscanberefinedtogettheactual
implementationofthesystem
UML DIAGRAMS

9
Five Views of a system
User’s view
Structural view
Behavioralview
Implementationview
Environmentalview
UML DIAGRAMS

10
UML DIAGRAMS
User’s View
-Use Case
Diagram
Structural View
-Class Diagram
-Object Diagram
Implementation View
-Component Diagram
Environmental View
-Deployment Diagram
Behavioural View
-Sequence Diagram
-Collaboration Diagram
-State-chart Diagram
-Activity Diagram
Diagrams and views in UML

USER’S VIEW
Definesthefunctionalities(facilities)madeavailable
bythesystemtoitsusers.
Black-boxviewofthesystem
-wheretheinternalstructure,thedynamicbehaviourof
differentsystemcomponents,theimplementationetc.
arenotvisible.
Consideredasthecentralviewandallotherviewsare
expectedtoconformtothisview.
11

STRUCTURAL VIEW
Definesthekindsofobjectsimportanttothe
understandingoftheworkingofasystemand
toitsimplementation.
Capturestherelationshipsamongtheobjects.
Calledthestaticmodel,sincethestructureofa
systemdoesnotchangewithtime.
12

BEHAVIORAL VIEW
Captureshowobjectsinteractwitheachother
torealizethesystembehavior.
Capturesthetime-dependent(dynamic)
behaviorofthesystem.
13

IMPLEMENTATION VIEW
Capturestheimportantcomponentsofthe
systemandtheirdependencies.
14

ENVIRONMENTAL VIEW
Modelshowthedifferentcomponentsare
implementedondifferentpiecesofhardware.
15

16
NO
Usecasemodel,classdiagramandoneof
theinteractiondiagramforasimple
system
Statechartdiagramincaseofmanystate
changes
Deploymentdiagramincaseoflarge
numberofhardwarecomponents
ARE ALL VIEWS REQUIRED?

17
USE CASE MODEL
Consistsofsetof“usecases”
Animportantanalysisanddesignartifact
Othermodelsmustconfirmtothismodel
Notreallyanobject-orientedmodel
Representsafunctionalorprocessmodel

18
USE CASES
Differentwaysinwhichsystemcanbeusedby
theusers
Correspondstothehigh-levelrequirements
Representstransactionbetweentheuserandthe
system
Definebehaviorwithoutrevealinginternal
structureofsystem
Setofrelatedscenariostiedtogetherbya
commongoal

19
USE CASES
Usecasesareindependentofeachother
Implicitdependenciesmayexist

20
EXAMPLE OF USE CASES
For library information system
issue-book
Query-book
Return-book
Create-member
Add-book, etc.

21
REPRESENTATION OF USE CASES
Representedbyusecasediagram
Usecaseisrepresentedbyellipse
Systemboundaryisrepresentedby
rectangle
Usersarerepresentedbystickpersonicon
(actor)
Communicationrelationshipbetween
actorandusecasebyline
Externalsystembystereotype

22
EXAMPLE OF USE CASES
TIC-TAC-TOE
Use case model
Tic-tac-toe game
Play Move
Player

23
WHY DEVELOP USECASE
DIAGRAM?
Servesasrequirementsspecification
Usersidentificationhelpsinimplementing
securitymechanismthroughloginsystem
Anotheruseinpreparingthedocuments
(e.g.user’smanual)

24
FACTORING USE CASES
Complexusecasesneedtobefactored
intosimplerusecases
Representcommonbehavioracross
differentusecases
Threewaysoffactoring
Generalization
Includes
Extends

GENERALIZATION
Generalizationworksthesamewaywithuse
casesasitdoeswithclasses.
Thechildusecaseinheritsthebehaviorand
meaningoftheparentusecase.
Thebaseandthederivedusecasesare
separateusecasesandshouldhaveseparate
textdescriptions. 25

26
FACTORING USING
GENERALIZATION
Pay membership fee
Pay through library pay cardPay through credit card
Use case generalization

INCLUDES
Involvesoneusecaseincludingthebehaviorof
anotherusecaseinitssequenceofeventsand
actions.
Theincludesrelationshipoccurswhenachunkof
behaviorthatissimilaracrossanumberofusecases.
Asshowninfig.,theincludesrelationshipis
representedusingapredefinedstereotype
<<include>>.
27

28
FACTORING USING INCLUDES
Base use case
Use case inclusion
Common
use case
<<include>>
Issue Book
Update
selected
book
Get user
selection
Check for
reservation
Renew Book
<<include>>
<<include>>
<<include>>
<<include>>
Paralleling model

EXTENDS
Itallowsyoutoshowoptionalsystembehavior.
Thisrelationshipamongusecasesisalsopredefined
asastereotype<<extends>>asshowninfig..
Similartogeneralizationbuttheextendingusecase
canaddadditionalbehavioronlyatanextension
pointonlywhencertainconditionsaresatisfied.
Theextendsrelationshipisnormallyusedtocapture
alternatepathsorscenarios.
29

30
FACTORING USING EXTENDS
Base
use case
Use case extension
Common
use case
<<extends>>

ORGANIZATION OF USE CASES
Whentheusecasesarefactored,theyare
organizedhierarchically.
Thehigh-levelusecasesarerefinedintoaset
ofsmallerandmorerefinedusecasesas
showninfig.
Top-levelusecasesaresuper-ordinatetothe
refinedusecases. 31

ORGANIZATION OF USE CASES
Therefinedusecasesaresub-ordinatetothe
top-levelusecases.
Onlythecomplexusecasesshouldbe
decomposedandorganizedinahierarchy.
Thislevelisalsoreferredtoasthecontext
diagram.
32

33
HIERARCHICAL ORGANIZATION
OF USE CASES
Hierarchical organization of use cases
External users
use case 1
use case 2
use case 3
use case 3.1
use case 3. 2
use case 3.3
use case 1
use case 2
use case 3
Subsystems
Method

34
CLASS DIAGRAM
Describesstaticstructureofasystem.
Showshowasystemisstructuredrather
thanhowitbehaves.
Mainconstituentsareclassesandtheir
relationships:
Generalization
Aggregation
Association
Variouskindsofdependencies

35
CLASS
Entitieswithcommonfeatures,i.e.attributesand
operations
Classesarerepresentedassolidoutlinerectanglewith
compartments
Classeshaveamandatorynamecompartmentwhere
thenameiswrittencenteredinboldface.

CLASS
Theclassnameisusuallywrittenusingmixed
caseconventionandbeginswithanuppercase.
Theclassnamesareusuallychosentobesingular
nouns.
Attributeandoperationcompartmentareoptional
forreusepurpose
36

ATTRIBUTES
Anattributeisapropertyofaclass.
Representskindofdatathatanobjectmightcontain.
Typeoftheattributeiswrittenbyappendingacolon
andthetypenameaftertheattributename.
Firstletterofaattributeisasmallletter.
Example:
bookName:String
37

OPERATION
Implementationofaservicethatcanberequested
fromanyobject.
Anobject’sdataorstatecanbechangedbyinvoking
anoperationoftheobject.
Aclassmayhaveanynumberofoperationsorno
operationatall.
Firstletterofanoperationnameisasmallletter.
Abstractoperationsarewritteninitalics.
38

OPERATION
Theparametersofanoperationmaybe
-‘in’,‘out’or‘inout’.
Example:
issueBook(inbookName):Boolean
39

40
EXAMPLE OF CLASS DIAGRAM
Different representations of the LibraryMember class
LibraryMember
Member Name
Membership Number
Address
Phone Number
E-Mail Address
Membership Admission Date
Membership Expiry Date
Books Issued
issueBook( );
findPendingBooks( );
findOverdueBooks( );
returnBook( );
findMembershipDetails( );
LibraryMember
Member Name
Membership Number
Address
Phone Number
E-Mail Address
Membership Admission Date
Membership Expiry Date
Books Issued
LibraryMember

41
ASSOCIATION RELATIONSHIP
Enableobjectstocommunicatewitheach
other
Describesaconnectionbetweenclasses.
Theassociationrelationbetweentwo
objectsiscalledobjectconnectionor
link.
Usuallybinaryrelationbutmoreclasses
canbeinvolved

ASSOCIATION RELATIONSHIP
Classcanhaverelationshipwithitself(recursive
association)
Associationbetweentwoclassesisrepresentedby
drawingastraightline
Thenameoftheassociationiswrittenalongside
theassociationline.
Arrowheadusedalongwithnameindicates
readingdirectionofassociation
Multiplicityindicateshowmanyinstancesofone
classareassociatedwitheachother.
42

43
ASSOCIATION RELATIONSHIP
Association between two classes
Library Member Book
1 *
borrowed by

44
AGGREGATION RELATIONSHIP
Involvedclassesarenotonlyassociatedto
eachotherbutalsorepresentawhole-part
relationship
Example:abookregisterisanaggregation
ofbookobject.
Representedbydiamondsymbolatthe
compositeend

AGGREGATION RELATIONSHIP
Cannotbereflexive(i.e.recursive)
-anobjectcannotcontainobjectsofthesame
classasitself.
Notsymmetric
-TwoclassesAandBcannotcontaininstancesof
eachother.
Itcanbetransitive
-Consistofanarbitrarynumberoflevels.
45

46
AGGREGATION RELATIONSHIP
Representation of aggregation
Document Line
1
*
Paragraph
1
*

COMPOSITIONRELATIONSHIP
Compositionisastricterformofaggregation.
Partsareexistence-dependentonthewhole.
Whenthewholeiscreated,thepartsarecreatedand
whenthewholeisdestroyed,thepartsaredestroyed.
Representedasafilleddiamonddrawnatthe
composite-end.
47

48
COMPOSITION RELATIONSHIP
Representation of composition
Order
1
*
Item

INHERITANCE RELATIONSHIP
Inheritancedescribes‘isa’/‘isakindof’
relationshipbetweenclasses.
Inheritanceisdefinedstatically.
Itcannotbechangedatrun-time.
49

50
INHERITANCE RELATIONSHIP

OBJECT DIAGRAM
Showsthesnapshotoftheobjectsinasystem.
Showsinstancesofclassesratherthanclasses
themselves,oftencalledinstancediagram.
Undergocontinuouschangeasexecution
proceeds.
Usefultoexplaintheworkingofasystem.
51

52
OBJECT DIAGRAM
Different representations of the LibraryMember object
LibraryMember
Mritunjay
B10028
C-108, Laksmikant Hall
1119
Mrituj@cse
25-02-04
25-03-06
NIL
IssueBook( );
findPendingBooks( );
findOverdueBooks( );
returnBook( );
findMembershipDetails( );
LibraryMember
Mritunjay
B10028
C-108, Laksmikant Hall
1119
Mrituj@cse
25-02-04
25-03-06
NIL
LibraryMember

53
INTERACTION DIAGRAM
Modelsthatdescribeshowgroupsof
objectsinteractamongthemselves.
Eachinteractiondiagramrealizes
behaviourofasingleusecase

54
INTERACTIONDIAGRAM
Twokinds:Sequence&Collaboration
Twodiagramsareequivalentinthesensethat
anyonediagramcanbederivedautomatically
fromtheotherbutportraysdifferentperspective
Thesediagramplayaveryimportantroleinthe
designprocess

55
SEQUENCE DIAGRAM
Showsinteractionamongobjectsastwo-
dimensionalchart
Thechartisreadfromtoptobottom.
Objectsareshownasboxesattopofchart.
Insidetheboxthenameoftheobjectiswritten
withacolonseparatingitfromthenameofthe
class.

SEQUENCE DIAGRAM
Boththenameoftheobjectandtheclass
areunderlined
Theobjectsappearingatthetopsignify
objectalreadyexistedwhentheusecase
executionwasinitiated.
Ifobjectcreatedduringexecutionthen
shownatappropriateplace.
56

SEQUENCE DIAGRAM
Objectsexistenceareshownasdashed
lines(object’slifeline)
Objectsactiveness,shownasrectangle
onlifelinecalledactivationsymbol.
Messagesareshownonarrows
57

58
SEQUENCEDIAGRAM
Messagelabelledwithmessagename
Messagecanbelabelledwithcontrol
information
Twotypesofcontrolinformation:
condition([])&aniteration(*)

EXAMPLE OFSEQUENCE
DIAGRAM
Thesequencediagramforthebookrenewal
usecasefortheLibraryAutomationSoftware
isshowninfig.
59

60
EXAMPLE OF SEQUENCE
DIAGRAM
:Library
Boundary
:Library
Book
Renewal
Controller
:Library
Book
Register
:Book
:Library
Member
renewBook
displayBorrowing
selectBooks
[reserved]
apology
confirm
find MemberBorrowing
bookSelected
* find
update
[reserved]
apology
confirm
updateMemberBorrowing
Sequence Diagram for the renew book use case

61
COLLABORATION DIAGRAM
Showsbothstructuralandbehaviouralaspects
Thestructuralaspectconsistsofobjectsand
thelinksexistingbetweenthem.
Objectsarecollaborator,shownasboxes
Thebehavioralaspectisdescribedbytheset
ofmessagesexchangedamongthedifferent
collaborators

COLLABORATION DIAGRAM
Linkbetweenobjectsshownasasolidline.
Messageisshownasalabelledarrow
placednearthelink
Messagesareprefixedwithsequence
numberstoshowrelativesequencing
62

63
EXAMPLE OF
COLLABORATION DIAGRAM
:Library
Boundary
:Library
Book
Renewal
Controller
:Library
Book
Register
:Book
:Library
Member
1: renewBook
3: display
Borrowing
4: selectBooks
[reserved]
8: apology
12: confirm
2: findMemberBorrowing
5: book
Selected
6: * find
9: update
[reserved]
7: apology
10: confirm
updateMemberBorrowing
Collaboration Diagram for the renew book use case

64
ACTIVITY DIAGRAM
Newconcept,possiblybasedonevent
diagramofOdell[1992]
Representprocessingactivity,maynot
correspondtomethodsofclasses
Activityisastatewithaninternalaction
andone/manyoutgoingtransition

65
ACTIVITY DIAGRAM
Normallyemployedinbusinessprocessmodelling
Carriedoutduringrequirementanalysisand
specification
Canbeusedtodevelopinteractiondiagrams

66
ACTIVITY DIAGRAM
Canrepresentparallelactivityand
synchronizationaspects
Importantfeatureofactivitydiagram
-Swimlanes
-enabletogroupactivitiesbasedonwho
isperformingthem
Example:academicdepartmentvs.hostel

EXAMPLE OF ACTIVITY
DIAGRAM
ThestudentadmissionprocessinIITisshownasan
activitydiagram.Thisshowsthepartplayedby
differentcomponentsoftheInstituteintheadmission
procedure.Afterthefeesarereceivedattheaccount
section,parallelactivitiesstartatthehosteloffice,
hospital,andtheDepartment.Afterallthese
activitiescomplete(thissynchronizationis
representedasahorizontalline),theidentitycardcan
beissuedtoastudentbytheAcademicsection.
67

68
EXAMPLE OF ACTIVITY
DIAGRAM
check
student
records
Academic Section
receive
fees
allot
room
receive
fees
allot
hostel
create
hospital
record
conduct
medical
examination
register
in
course
Accounts Section Hostel Office Hospital Department
issue
identity card
Activity diagram for student admission procedure at IIT

69
STATE CHART DIAGRAM
BasedontheworkofDavidHarel[1990]
Modelhowthestateofanobjectchangesinits
lifetime
Describehowthebehavioroftheobjectchanges
acrossseveralusecaseexecution.
Basedonfinitestatemachine(FSM)formalism

70
WHY STATE CHART DIAGRAM
Statechartavoidsproblemofstateexplosionas
inFSM
Stateexplosion
-Thenumberofstatesbecomestoomanyand
themodeltoocomplex.
Hierarchicalmodelofasystemandrepresents
compositestate(nested)

71
STATE CHART DIAGRAM
Elementsofstatechartdiagram
InitialState:Filledcircle
FinalState:Filledcircleinsidelargercircle
State:Rectanglewithroundedcorners
Transitions:Arrowbetweenstates,also
booleanlogiccondition(guard).
Thesyntaxforthelabelofthetransitionis:
event[guard]/action.

EXAMPLE OFSTATECHART
DIAGRAM
An example of state chart for the order
object of the Trade House Automation
software is shown in fig.
72

73
EXAMPLE OF STATE CHART
DIAGRAM
Unprocessed
Order
Fulfilled
Order
Pending
Order
Accepted
Order
Rejected
Order
order received
[reject] checked
[accept] checked
[some items not
available] processed
[all items
available]
newsupply
[some items available]
processed / deliver
Example: State chart diagram for an order object

COMPONENT DIAGRAM
Pieceofasoftwarethatcanbe
independentlypurchased,upgradedand
integratedintoexistingsoftware.
Representthephysicalstructureof
implementation
74

COMPONENT DIAGRAM
Usedfortwopurposes:
Organizingsourcecode
Specifydependenciesamongdifferent
components.
75

DEPLOYMENT DIAGRAM
Showstheenvironmentalviewofthesystem.
Showshowthesoftwaresystemwillbe
physicallydeployedinthehardware
environment.
Diagrammodelstheruntimearchitectureof
anapplication.
76
Tags