1
iUML-BClassDiagrams
2
Mo3va3on
ProvideamoreapproachableinterfacefornewcomerstoEvent-BProvidediagramstohelpvisualisemodelsProvideextramodellingfeaturestoEvent-B
SequencingofEvents(seeState-machines)LiGingofBehaviourtoasetofinstances(O-O)
N.b.nottryingtoformaliseUML
3
WhatisiUML-B?
AGraphicalfront-endforEvent-B► Plug-inforRodin
NotUML…
► Hasitsownmeta-model(abstractsyntax)► Seman3csinheritedfromtransla3ontoEvent-B
…butithassomesimilari3eswithUML► ClassDiagrams► StateMachineDiagrams
TranslatorgeneratesEvent-Bautoma3cally
► Intothesamemachine (generated=readonly)► CanalsowritestandardEvent-Binthesamemachine+events
4
Whatarethebenefits?
Visualisa3on► Helpsunderstanding► communica3on
Fastermodelling► Onedrawingnode=severallinesofB► Extrainforma3oninferredfromposi3on(containment)ofelements► Experimentwithdifferentabstrac3ons
Providesstructuringconstructs► Hierarchicalstate-machines
Event-Bhasnoeventsequencingmechanism
► Class DataEn3tyrela3onships,LiGedmethodsandstate-machinesEvent-Bhasnoli-ingmechanism
findingusefulabstrac4onsishard
5
ClassDiagrams
ClassDiagramsprovideawaytomodelDataassets(classes)ofobjects.EachclasslinkstoaCarrierSet,ConstantorVariableintheEvent-B
ClassC1islinkedtothecarriersetC1
incontextx0seenbymachinem0 (Theclassdiagramisinm0)
Linkingtoanexis4ngdataelementallowsmoreflexibility.Abu@onenablesdatatobecreatedfromtheclassdiagram
6
SelfName
Eachclasshasaselfname.Thisisaniden3fierthatreferstoanexampleinstanceoftheclass.
Thedefaultselfnameisthis_<classname>. Itcanbechangedintheproper3esviewaGerselec3ngtheclass.
N.B.Theproper4esviewisalsousedtolinktheclasstodataofthemachineorcontextasdescribedinthepreviousslide.
7
Supertype
ClassSupertyperela3onshipsgenerateanaxiomorinvariant.
ClassC2islinkedtoavariableC2hasC1asitssupertypeThisgeneratesaninvariantinm0whichtypesC2(n.b.subtypesareNOTassumedtobedisjoint)
8
Aeribute
Aclass(i.e.eachofitsobjects)mayhaveaeributesTheaeributehasatypewhichmaybeanyvalidEvent-B(sub)set
Theaeributelinkstoavariable(orconstant)whichisarela3onbetweenclassinstancesandvaluesfromtheaeributestype.(foraeributesweusuallymaketherela3onatotalfunc4on)
9
Associa3on
Aclassmayhaveassocia3onswithotherclasses
Theassocia3onlinkstoavariable(orconstant)whichisarela3onbetweenclassinstancesandtargetclassinstances.(thecardinali3esdeterminethekindofrela3on:surjec3veinjec3ve,func3onaletc.)
10
Methods
Themethodlinkstoaneventinthemachine.Theeventautoma3callygetsaparameterfortheclassinstance.Otherparameters,guardsandac3onscanbeaddedtothemethod(usingtheproper3esview)
Aclassmayhavemethods
11
ConstructorsandDestructors
Foraconstructor,anunusedinstanceisaddedtotheclass.Anyaeributesareini3alisedfortheinstance
Aclassmethodcanbemadeaconstructorordestructorbysehngthekindparameterintheproper3esview.(Theclassmustlinktoavariablesetofinstances)
Foradestructor,ausedinstanceisremovedfromtheclass.Anyaeributesarealsoremovedfortheinstance
12
Constraints
Aclassmaycontainconstraints
Theconstraintgeneratesaninvariantinthemachine*Thegenera3onaddsanantecedentthatuniversallyquan3fiestheconstraintforallclassinstances.(Thisquan3fica3onisimplicitintheclassdiagram)
*anaxiomiftheclassdiagramiscontainedinacontext
13
Refinement
Whenamachinewithaclassdiagramisrefined, arefinedclassdiagramiscreatedintherefinedmachine.
Itcontainsarefinedclassinsteadofeachoriginalclass.Theydonotgenerateanyinvariantsbutcanbeusedinfornewmodelling(eitheraddingtotheircontentorastargetsinassocia3onandsupertype).Aeributesandassocia3onsareretainedasinherited.Theydonotgenerateanyinvariants.Methodsareretainedasrefinedversionslinkingtothecorrespondingrefinedeventsprovidingabasisforrefinement.
14
Example–AccessControl
enter any r : ROOM where
takeplace[{r}] ⊆ authorised[{this_USER}] when
location ≔ location {(this_USER↦r)}
1)Ac3vi3estakeplaceinRooms2)Usersareauthorisedtocarryoutac3vi3es3)UsersmayenterRoomsonlyiftheyareauthorisedtocarryoutalltheac3vi3es
thattakeplaceinthatroom
15
Example–AccessControlRefinement
4)UsersareallocatedTokens(allocateTokenisaconstructorandsetsholder)5)HoldingaTokenenablesaccesstoRooms6)Tokensexpire(expireTokenisadestructor)
16
Installa3onHelp–InstallNewSoGware…
17
Summary
ClassDiagramsformodellingdatarela3onshipsClasses–sets(CarrierSets,ConstantsVariables)
selfnameSupertypes-subsetsAeributes–rela3ons(usuallyfunc3ons)Associa3ons-rela3onsMethods–events
constructorsanddestructorsConstraints–invariantsorAxiomsRefinedClasses
Top Related