THE LIFE OF AN OBJECT IT SYSTEMS Persns, bjects, r cncepts frm the real wrld, which we mdel as bjects in the IT system, have "lives". Actually, they have tw lives; the riginal in the real wrld has a life, and ur image, the bject, has a life as well. Thugh these tw lives are related, they d nt necessarily fllw the same curse. Usually, a life starts at birth, creatin, r generatin and ends with death, deletin, r destructin. In between, life fllws a mre r less rdered curse, as illustrated in Figure 4.43: Figure 4.43 The life f a plane T illustrate what we mentined befre we wuld like t take a clser lk at the life f a plane. The plane that we wuld like t lk at is an Airbus A330-223 f Swiss Internatinal Airlines with the registratin number HB-IQI. The birth f the Airbus A330-223 (f the riginal) ccurs, depending n the perspective, at the start f cnstructin r at the first flight. The birth f the bject f the Airbus A330-223 in the IT system ccurs when infrmatin abut the plane is recrded fr the first time. This can be at the pint f purchase, since the plane culd be recrded in the IT system fr
planning purpses, r when the plane is delivered. The initiatr fr the birth f an bject in the IT system is always a mutatin event. Because cmmercial airplanes are ften sld lng befre cnstructin begins, it is pssible that the birth f the bject ccurs befre the (physical) birth f the plane. The death f the riginal has t d with physical destructin. In the case f ur Airbus A330-233 death ccurs at withdrawal r pssibly in a plane crash. The death f the bject ccurs, when the bject is deleted frm the IT system f Swiss Airline. The initiatr fr the death f an bject in the IT system is always a mutatin event. Because cmmercial airplanes are ften sld n after a certain perid f time, it is pssible that the (lgical) death f an bject in the IT system ccurs befre the (physical) death f the riginal. Between birth and death the bject is alive in the IT system, that is, it will be read and changed. It will be read as the result f a query event; it will be changed as the result f a mutatin event (see Query Events and Mutatin Events). As lng as reading and mdifying bjects are nt subject t any restrictins, this is nt especially interesting. It can be described in a simple statechart diagram (see Figure 4.44). Hwever, as sn as rules fr mdificatin have t be bserved, it becmes imprtant t dcument these rules smewhere. Here, we are talking abut dynamic business rules (see Static and Dynamic Business Rules). Dynamic business rules are rules that nly apply at a certain pint in time, namely when a query event r a mutatin event ccurs. The behavir f bjects is largely determined by such dynamic business rules. Examples f dynamic business rules are: A plane cannt be assigned a flight during the time it is in maintenance. A plane cannt be withdrawn as lng as it is still scheduled fr flights. If we take a clser lk at these business rules, we recgnize that they refer t certain events n the ne hand, and t states f the bject n the ther hand: The mutatin event assigning a flight t a plane is nt permitted in the state in maintenance f the bject plane. The mutatin event withdrawing plane is nt permitted in the state flights scheduled f the bject plane. The mutatin event starting plane is nt permitted in the state in transit f the bject plane.
In ther wrds: Fr certain events it shuld be pssible t determine if an event is permitted in the current state f the bject, and hw the bject will react t the event. Cnsider the dynamic business rules that culd apply t the bject plane ticket in a passenger services system. In the behaviral view, ne statechart diagram per class is used t dcument which dynamic business rules have t be fllwed, and which events are allwed in which states f bjects. In the simplest case, all events are allwed. Figure 4.44 shws a simple statechart diagram fr the class frequent flyer card: Figure 4.44 Simple statechart diagram fr the frequent flyer card A new bject is created by the event «M» New Card (1). An bject is deleted by the event «M» Delete Card (2). In between the bject is in the state Nrmal (3), in which "all ther events" (4) are allwed (in a real statechart diagram the events that are actually allwed have t be listed by name instead f the event "all ther events"). If, hwever, we add business rules, the statechart diagram becmes mre cmplex. We wuld like t amend ur statechart diagram with the fllwing rules: It has t be pssible t suspend and reinstate a frequent flyer card. It is nt pssible t add any miles t a suspended frequent flyer card. If we amend ur statechart diagram with the mentined dynamic business rules, the diagram depicted in Figure 4.45 is created:
Figure 4.45 Mre cmplex statechart diagram fr the frequent flyer card A statechart diagram, such as the ne f the frequent flyer card in Figure 4.45, shws n which paths r within which bundaries the life f a frequent flyer card bject can prceed. In the diagram, pssible and impssible chains f events can be recgnized. A pssible flw is, fr instance, «M» new card,«m» add miles, «M» add miles, «M» add miles, «M» suspend card, «M» delete card. An example f a sequence that is nt permitted is: «M» new card, «M» add miles, «M» add miles,«m» suspend card, «M» add miles, «M» delete card. The secnd t last event, «M» add miles, is nt accepted. If the card were unsuspended, miles culd be added t it again. Cnsider whether r nt the fllwing chains f events are permitted accrding t the statechart diagram f the class frequent flyer card in Figure 4.45: «M» add miles, «M» add miles, «M» add miles, «M» delete card, «M» delete card. «M» new card, «M» add miles, «M» suspend card, «M» unsuspend card, «M» add miles, «M» delete card. «M» new card, «M» add miles, «M» suspend card, «M» suspend card, «M» delete card. Generally, the life f an bject fllws such a predetermined curse, meaning that the bject has t fllw certain rules. Thus, the behaviral view is especially imprtant, because it is the jb f the IT system t ensure that these rules are fllwed. It is imprtant that rules are dcumented in a crrect and cmplete manner, t avid misunderstandings n bth the user side and the develper side. In a cmpleted IT system, it shuld nt be pssible fr a user t delete r mdify bjects when it is nt permitted by business rules. In the Hanseatic Merchant's trading ffice, an bject crrespnds t a bk, fr instance, the rder bk, and the clerk wh is respnsible fr that bk. The statechart
diagram f the bject cntains the rules that the clerk has t fllw when he handles the bk. It is his instructin manual. It states, fr example, that an rder that has already been delivered, but that is nt yet paid fr, cannt be canceled. If yu culd sit next t the clerk fr a while and watch him d his wrk, yu wuld be able t see everything that can happen with an rder in the rder bk. It can, fr example, be recrded, mdified, delivered, canceled, r paid fr. The statechart diagram f the behaviral view cntains the result f this bject bservatin.