Download - iUML-B Class Diagrams · Class Diagrams Class Diagrams provide a way to model Data as sets (classes) of objects. Each class links to a Carrier Set, Constant or Variable in the Event-B

Transcript
Page 1: iUML-B Class Diagrams · Class Diagrams Class Diagrams provide a way to model Data as sets (classes) of objects. Each class links to a Carrier Set, Constant or Variable in the Event-B

1

iUML-BClassDiagrams

Page 2: iUML-B Class Diagrams · Class Diagrams Class Diagrams provide a way to model Data as sets (classes) of objects. Each class links to a Carrier Set, Constant or Variable in the Event-B

2

Mo3va3on

ProvideamoreapproachableinterfacefornewcomerstoEvent-BProvidediagramstohelpvisualisemodelsProvideextramodellingfeaturestoEvent-B

SequencingofEvents(seeState-machines)LiGingofBehaviourtoasetofinstances(O-O)

N.b.nottryingtoformaliseUML

Page 3: iUML-B Class Diagrams · Class Diagrams Class Diagrams provide a way to model Data as sets (classes) of objects. Each class links to a Carrier Set, Constant or Variable in the Event-B

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

Page 4: iUML-B Class Diagrams · Class Diagrams Class Diagrams provide a way to model Data as sets (classes) of objects. Each class links to a Carrier Set, Constant or Variable in the Event-B

4

Whatarethebenefits?

Visualisa3on►  Helpsunderstanding►  communica3on

Fastermodelling►  Onedrawingnode=severallinesofB►  Extrainforma3oninferredfromposi3on(containment)ofelements►  Experimentwithdifferentabstrac3ons

Providesstructuringconstructs►  Hierarchicalstate-machines

Event-Bhasnoeventsequencingmechanism

►  Class DataEn3tyrela3onships,LiGedmethodsandstate-machinesEvent-Bhasnoli-ingmechanism

findingusefulabstrac4onsishard

Page 5: iUML-B Class Diagrams · Class Diagrams Class Diagrams provide a way to model Data as sets (classes) of objects. Each class links to a Carrier Set, Constant or Variable in the Event-B

5

ClassDiagrams

ClassDiagramsprovideawaytomodelDataassets(classes)ofobjects.EachclasslinkstoaCarrierSet,ConstantorVariableintheEvent-B

ClassC1islinkedtothecarriersetC1

incontextx0seenbymachinem0 (Theclassdiagramisinm0)

Linkingtoanexis4ngdataelementallowsmoreflexibility.Abu@onenablesdatatobecreatedfromtheclassdiagram

Page 6: iUML-B Class Diagrams · Class Diagrams Class Diagrams provide a way to model Data as sets (classes) of objects. Each class links to a Carrier Set, Constant or Variable in the Event-B

6

SelfName

Eachclasshasaselfname.Thisisaniden3fierthatreferstoanexampleinstanceoftheclass.

Thedefaultselfnameisthis_<classname>. Itcanbechangedintheproper3esviewaGerselec3ngtheclass.

N.B.Theproper4esviewisalsousedtolinktheclasstodataofthemachineorcontextasdescribedinthepreviousslide.

Page 7: iUML-B Class Diagrams · Class Diagrams Class Diagrams provide a way to model Data as sets (classes) of objects. Each class links to a Carrier Set, Constant or Variable in the Event-B

7

Supertype

ClassSupertyperela3onshipsgenerateanaxiomorinvariant.

ClassC2islinkedtoavariableC2hasC1asitssupertypeThisgeneratesaninvariantinm0whichtypesC2(n.b.subtypesareNOTassumedtobedisjoint)

Page 8: iUML-B Class Diagrams · Class Diagrams Class Diagrams provide a way to model Data as sets (classes) of objects. Each class links to a Carrier Set, Constant or Variable in the Event-B

8

Aeribute

Aclass(i.e.eachofitsobjects)mayhaveaeributesTheaeributehasatypewhichmaybeanyvalidEvent-B(sub)set

Theaeributelinkstoavariable(orconstant)whichisarela3onbetweenclassinstancesandvaluesfromtheaeributestype.(foraeributesweusuallymaketherela3onatotalfunc4on)

Page 9: iUML-B Class Diagrams · Class Diagrams Class Diagrams provide a way to model Data as sets (classes) of objects. Each class links to a Carrier Set, Constant or Variable in the Event-B

9

Associa3on

Aclassmayhaveassocia3onswithotherclasses

Theassocia3onlinkstoavariable(orconstant)whichisarela3onbetweenclassinstancesandtargetclassinstances.(thecardinali3esdeterminethekindofrela3on:surjec3veinjec3ve,func3onaletc.)

Page 10: iUML-B Class Diagrams · Class Diagrams Class Diagrams provide a way to model Data as sets (classes) of objects. Each class links to a Carrier Set, Constant or Variable in the Event-B

10

Methods

Themethodlinkstoaneventinthemachine.Theeventautoma3callygetsaparameterfortheclassinstance.Otherparameters,guardsandac3onscanbeaddedtothemethod(usingtheproper3esview)

Aclassmayhavemethods

Page 11: iUML-B Class Diagrams · Class Diagrams Class Diagrams provide a way to model Data as sets (classes) of objects. Each class links to a Carrier Set, Constant or Variable in the Event-B

11

ConstructorsandDestructors

Foraconstructor,anunusedinstanceisaddedtotheclass.Anyaeributesareini3alisedfortheinstance

Aclassmethodcanbemadeaconstructorordestructorbysehngthekindparameterintheproper3esview.(Theclassmustlinktoavariablesetofinstances)

Foradestructor,ausedinstanceisremovedfromtheclass.Anyaeributesarealsoremovedfortheinstance

Page 12: iUML-B Class Diagrams · Class Diagrams Class Diagrams provide a way to model Data as sets (classes) of objects. Each class links to a Carrier Set, Constant or Variable in the Event-B

12

Constraints

Aclassmaycontainconstraints

Theconstraintgeneratesaninvariantinthemachine*Thegenera3onaddsanantecedentthatuniversallyquan3fiestheconstraintforallclassinstances.(Thisquan3fica3onisimplicitintheclassdiagram)

*anaxiomiftheclassdiagramiscontainedinacontext

Page 13: iUML-B Class Diagrams · Class Diagrams Class Diagrams provide a way to model Data as sets (classes) of objects. Each class links to a Carrier Set, Constant or Variable in the Event-B

13

Refinement

Whenamachinewithaclassdiagramisrefined, arefinedclassdiagramiscreatedintherefinedmachine.

Itcontainsarefinedclassinsteadofeachoriginalclass.Theydonotgenerateanyinvariantsbutcanbeusedinfornewmodelling(eitheraddingtotheircontentorastargetsinassocia3onandsupertype).Aeributesandassocia3onsareretainedasinherited.Theydonotgenerateanyinvariants.Methodsareretainedasrefinedversionslinkingtothecorrespondingrefinedeventsprovidingabasisforrefinement.

Page 14: iUML-B Class Diagrams · Class Diagrams Class Diagrams provide a way to model Data as sets (classes) of objects. Each class links to a Carrier Set, Constant or Variable in the Event-B

14

Example–AccessControl

enter any r : ROOM where

takeplace[{r}] ⊆ authorised[{this_USER}] when

location ≔ location {(this_USER↦r)}

1)Ac3vi3estakeplaceinRooms2)Usersareauthorisedtocarryoutac3vi3es3)UsersmayenterRoomsonlyiftheyareauthorisedtocarryoutalltheac3vi3es

thattakeplaceinthatroom

Page 15: iUML-B Class Diagrams · Class Diagrams Class Diagrams provide a way to model Data as sets (classes) of objects. Each class links to a Carrier Set, Constant or Variable in the Event-B

15

Example–AccessControlRefinement

4)UsersareallocatedTokens(allocateTokenisaconstructorandsetsholder)5)HoldingaTokenenablesaccesstoRooms6)Tokensexpire(expireTokenisadestructor)

Page 16: iUML-B Class Diagrams · Class Diagrams Class Diagrams provide a way to model Data as sets (classes) of objects. Each class links to a Carrier Set, Constant or Variable in the Event-B

16

Installa3onHelp–InstallNewSoGware…

Page 17: iUML-B Class Diagrams · Class Diagrams Class Diagrams provide a way to model Data as sets (classes) of objects. Each class links to a Carrier Set, Constant or Variable in the Event-B

17

Summary

ClassDiagramsformodellingdatarela3onshipsClasses–sets(CarrierSets,ConstantsVariables)

selfnameSupertypes-subsetsAeributes–rela3ons(usuallyfunc3ons)Associa3ons-rela3onsMethods–events

constructorsanddestructorsConstraints–invariantsorAxiomsRefinedClasses