On the Description of Communictions Between Softwre Components with UML Zhiwei An Dennis Peters Fculty of Engineering nd Applied Science Memoril University of Newfoundlnd St. John s NL A1B 3X5 zhiwei@engr.mun.c Novemer 12, 2003 dpeters@engr.mun.c Astrct For the purpose of nlysis nd verifiction, in softwre design, rchitecture of the softwre system nd communictions etween softwre components should e specified. Unified Modeling Lnguge (UML) is stndrd softwre design nottion tht includes Sequence digrms nd Collortion digrms, which descrie the interction etween ojects. They lso cn e used to descrie communictions etween components. In this pper, we discuss wht should e modeled in the communiction nd how the elements in UML cn e dopted to model the communiction. A formlism of UML design models tht cn e used for design nlysis is lso proposed. 1 Introduction Softwre systems re often composed of severl components ech of which is computtionl entity tht relizes prticulr function. Components interct with ech other y communictions etween them. Documenting communictions is one prt of softwre design nd the design models should e verifile to ensure the correctness of the design. In softwre systems, synchronous nd synchronous communiction could exist. To descrie different types of communictions etween components, severl methodologies hve een proposed. Two kinds of methods re 1) Architecturl Description Lnguges (ADL) [1] nd 2) UML in rchitecture description [3, 4]. The Unified Modeling Lnguge (UML) [6] is stndrd modeling lnguge with rich digrms to model sttic nd dynmic spects of system. Sequence digrms nd collortion digrms re two types of UML digrms widely used in communiction description. In sequence digrm, the horizontl dimension represents different ojects nd the verticl dimension represents time. Ech oject hs lifeline with ctivtion rs. The r egins with the invoction of method nd stops when the method ends. Arrows represent messges trnsmitted etween the ojects. The life line could hve rnch t time point nd the two or more lines could merge t lter time. The rnch mens conditionl rnch or concurrency. Sequence digrms specify time explicitly. In sequence digrm, ojects interct with ech other vi messges. A messge my specify severl different time points such s sending time nd receiving time. One messge links two events nd the order of events is specified. A collortion digrm presents set of roles to e plyed y instnces s well s required reltionships etween them. It lso presents set of messges specifying the interction etween the instnces plying the roles to chieve the desired result. In collortion digrms, messge order is descried y dding numers to rrow lels. 1
To verify the UML design models, the ide of model checking [2] is proposed. Typiclly, model checking lgorithm checks properties of system description sed on (finite) stte mchine model with prllel composition. To generte the utomt sed model, sequence digrms should e nlyzed nd trnslted into stte mchines. A sequence digrm descries time explicitly so the timing reltion of the events cn e derived from it. In UML design models for softwre system there re usully severl sequence digrms. Anlysis of ll of these digrms could generte stte mchine sed model for model checking. The rest of this pper is orgnized s follows: In Section 2, we discuss types of communictions etween softwre components nd wht should e modeled in the communiction. Section 3 uses n simplified elevtor exmple to show how to use UML digrms to descrie interctions. In Section 4, we propose one ehvior model of the softwre system nd illustrte how informtion in Sequence digrms could e mpped to the ehvior model. In Section 5, we drw some conclusions. 2 Types of Communictions Communictions etween softwre components re either synchronous or synchronous. The difference etween these two clsses of communictions is tht synchronous communictions involves locking opertions in the communiction. In synchronous communiction, the component is suspended fter the send opertion until it is unlocked y the other prtner in the communiction. In synchronous communiction, nonlocking opertions re used which mens tht the components will proceed without witing for the completion of the communiction. The following clsses of communictions re possile. Shred Vrile A vrile tht cn e ccessed y more thn one component is mens of communiction. The sic opertions on shred vrile re red nd write so mutul exclusion is the min prolem in this type. Asynchronous Messge Pssing (AMP) In this type of communiction, there re two events 1) the sender sends out the messge nd continues running, 2) the receiver receives the messge. If the receiver is ville nd the processes re co-locted, 1 nd 2 hppen t essentilly the sme time nd could e considered s the sme event. If the receiver is not ville, the messge is stored in uffer until the receiver is ville. The sender is not locked t ny time. Synchronous Messge Pssing (SMP) In Synchronous Messge Pssing, the sender cnnot send the messge until the receiver is ville to receive it. There is no uffer in this type of communiction. Procedure Cll In Procedure Cll, there re four events 1) the cller clls n ccess progrm in the cllee, 2) the ccess progrm is invoked, 3) the ccess progrm finishes, nd 4) the cller knows tht the cllee finishes. In Procedure Cll 1 nd 2 hppen t the sme time nd they could e considered s one event. 3 nd 4 re lso the sme event. Between the events of 2 nd 3, the cller is locked. Remote Procedure Cll When there re more thn one process nd process clls function in nother process, this type of communiction is clled Remote Procedure Cll (RPC). The mechnism of RPC is lmost the sme s procedure cll except tht the function in nother process my e unville ecuse tht function is clled y nother component nd it cn not e clled twice t the sme time. Asynchronous communiction nd synchronous communiction hve the similr semntics nd cn e modeled in similr wy. For exmple, synchronous messge pssing is specil cse of synchronous messge pssing without uffer nd synchronous messge pssing etween two components could e modeled s two synchronous messges: from one component to uffer nd then from the uffer to the other component. 2
Tle 1: Concepts in Communiction nd UML Communiction Concepts UML Nottions Component Component s Life Running Access Progrm Messges or Clls (Opertions) Messge Nme or Cll Nme Event Oject Lifeline Activtion Br Messge Arrow Arrow Lel Two Ends of n Arrow Two ends of n Activtion Br 3 Description of Communictions in UML The techniques for denoting communiction types in UML re defined in UML 1.4. To descrie communictions with UML, the first step is to mp concepts in communiction to the elements in UML digrm. Tle 1 illustrtes the reltions of UML nottions nd concepts of communiction in this work. Opertions nd events should e distinguished here: opertions hve time durtion nd they re often composed of severl events which re points in time. Some concepts in communiction cnnot e represented y UML nottions. For exmple, the dt stte is not in UML t ll nd control stte my e represented implicitly. After mpping concepts of communictions to elements of UML, we need to model communictions with the semntics of collortion digrms nd sequence digrms. To descrie the whole system, the first step is to use collortion digrms to descrie reltions etween ojects, the second step is to use sequence digrms to descrie interctions. 3.1 Collortion Digrms in Communiction Becuse collortion digrm presents collection of instnces nd their reltionships, we cn use it to descrie the reltions etween components, s illustrted in Figure 1. The rrows etween components represent messges nd clls. Since this digrm only illustrtes the sttic reltions etween components no numer is used in the rrow lel. elevtora:elevtor elevtorb:elevtor crarrived nextstop getfloor getdirection schedulera:scheduler coordintor:coordintor schedulerb:scheduler schedule remove schedule remove crreq destintionrequesta :destintionrequest schedule remove remove schedule crarrived nextstop destintionrequestb :destintionrequest getfloor getdirection destrequest crrequest: crrequest destrequest crrequest Figure 1: Elevtor System in Collortion Digrm 3.2 Sequence Digrms in Communiction A sequence digrms descries severl spects of the communiction. First, it cn descrie the phenomenon of when one ccess progrm is invoked, wht other events could e generted during the run time of the 3
ccess progrms. Second, it cn illustrte the mechnism of communiction. When one ccess progrm is invoked, it my send messges to or cll ccess progrms in other components. Messges nd clls re distinguished y different types of rrows. For exmple, Figure 2 shows tht when the ccess progrm schedule is invoked, three opertions, getfloor, getdirection nd nextstop hppen. Figure 3 illustrtes the order of the events in the cse of AMP. destntion RequestA schedulera elevtora crrequest coordintor schedulera schedulerb destrequest schedule getfloor crrequest crreq schdule schdule getdirection nextstop Figure 2: Stimulus in UML, I Figure 3: Stimulus in UML, II Since there re finite numer of ccess progrms in the system nd we cn drw one sequence digrm for ech ccess progrm, the numer of sequence digrms is equl to the numer of ccess progrms nd hence the numer of sequence digrms will not grow too rpidly s the system size increses. Figure 2 nd Figure 3 only illustrte the ehviour when one ccess progrm is invoked. More sequence digrms re needed to completely descrie the communictions etween components, including conflict resolution. Figure 4 illustrtes ll types of communictions discussed in Section 2. In I, procedure cll is illustrted: component P clls n ccess progrm in component Q (opertion ). The ccess progrm in Q is invoked t the sme time s the component P clls it nd P is locked. After the ccess progrm in Q ends, P is unlocked. In II, P clls Q (opertion ) first nd it is locked until the opertion. If Q is unville nd R wnts to cll Q, R is locked nd should wit until the opertion is over. R will e unlocked only fter the opertion d. In III, P sends messge (opertion ) to Q nd P is not locked. If Q is not ville efore it finishes serving the messge form P nd R sends messge to it (opertion ), uffer is used to store the messge nd re-send the messge to Q (opertion c) fter Q is ville. In this type of communiction, no component is locked. In IV, P sends messge to Q (opertion ), R sends messge to Q (opertion ) when Q is not ville nd R is locked, this opertion cn finish only fter Q finishes serving the messge from P. When the opertion ends, R is unlocked nd Q egins to serve the messge from R. In V, red nd write re two sic opertions nd they should oey the rules of mutul exclusion. P Q P Q R P Q uffer R c d c I. Procedure Cll II. Remote Procedure Cll III. Asynchronous Messge Pssing P Q R P vr R P,Q,R re components,, c, d re messges or clls vr is shred vrile c red write red write IV. Synchronous Messge Pssing V. Shred Vrile Figure 4: Types of Communiction in UML 4
Figure 4 only illustrtes some sic types of communictions. In relistic system mixtures nd vrints of these communictions exist. In Figure 5, the communiction re AMP. In this exmple, the coordintor cn ccess two messges from two schedulers so we cn drw two lifelines for coordintor. A uffer is necessry when messge cnnot e processed immeditely fter eing sent. schedulera:scheduler coordintor uffer schedulerb:scheduler Figure 5: Communiction Mechnism 4 Anlysis Technique To verify UML design models, we need formlism to ccept ll sequences of events descried y the model. In softwre systems, components re modeled s stte mchines nd most model checking lgorithms ccept utomt sed specifiction s the input, so prllel composition of stte mchines is the model in this reserch work. 4.1 From UML to Stte Mchine Model Sequence digrms descrie the reltive order of events. In communictions, there re severl possile orders of events so the events re not totlly ordered. The est description of the reltionship of events is prtil order. In [5], reltions of messges in Messge Sequence Chrts (MSC) re trnslted into prtil order. Becuse sequence digrms come from MSCs with extension, similr process cn e used to extrct the prtil order from sequence digrms. UML Sequence digrms do not hve stte vriles in them so they do not represent component stte precisely. UML Sttechrts hve the ility to descrie the ehvior of the component ut Module Interfce Specifictions (MIS)[7] mke etter use of strction nd re more menle to mchine processing. A discussion of the process for generting forml ehviour model from component MIS is eyond the scope of this pper. From the discussion ove, we cn propose tht the prolem of synthesizing concurrent utomt from Sequence digrms cn e divided into two steps. 1)Descrie prtil order reltion in sequence digrms formlly nd 2)synthesizing concurrent utomt model from the prtil order reltions nd component MIS. 5 Conclusion UML interction digrms hve the ility to descrie the communiction etween softwre components. Collortion digrms descrie the reltions etween components nd sequence digrms descrie two spects of the interction: 1) when one event hppens, wht other events could hppen, nd 2) wht communictions mechnisms represent the communiction types. To verify softwre design, n utomt sed ehvior model could e derived from the sequence digrms nd used for model checking. 5
References [1] Roert Allen nd Dvid Grln. A forml sis for rchitecturl connection. ACM Trns. Softwre Eng. nd Methodology, July 1997. [2] E. M. Clrk, O. Grumerg, nd D. Peled. Model Checking. MIT Press, 2000. [3] Hssn Gom. Designing Concurrent, Distriuted, nd Rel-Time Applictions with UML. Addison- Wesley, 2000. [4] Christine Hofmeister, Roert Nord, nd Dilip Soni. Applied Softwre Architecture. Addison-Wesley, 2000. [5] Mdhvn Mukund, K. Nryn Kumr, nd Milind Sohoni. Synthesizing distriuted finite-stte systems from MSCs. In Proc. Int l Conf. Concurrency Theory (CONCUR), numer 1877 in Lecture Notes in Computer Science, pges 521 535, University Prk, PA, 2000. Springer-Verlg. [6] Rtionl Softwre Inc., et l. OMG Unified Modelling Lnguge Specifiction, version 1.5 edition, Mrch 2003. [7] Yo Wng. Forml nd strct softwre module specifictions survey. CRL Report 238, Communictions Reserch Lortory, Hmilton, Ontrio, Cnd, Novemer 1991. 6