To complete the specification of activity diagrams, OCL expressions can be used in the same ways as in interaction diagrams:
For activity diagrams, an OCL expression can be used to indicate the instance that is executing an activity. The contextual instance for all expressions in the diagram is the instance that executes (or controls) the overall activity that contains this diagram as a specification of its internal implementation. Activity diagrams are also used to specify the flow of a complete system or business. In that case no object executes the overall activity. (One might argue that the system or company executes the overall activity.) Therefore, the keyword self cannot be used. See Section 3.8 for a further discussion of the implications of this case. Figure 3-10 shows the specification of the operation addService(s:Service, p:ProgramPartner) of class LoyaltyProgram . This diagram contains examples of all possible uses of OCL. The first activity (from the top) takes one actual parameter: s.level . This the ServiceLevel level from the Service s . Both the first and second activities from the top are executed by the contextual instance indicated by the keyword self , whereas the middle activity is executed by the program partner instance that is the parameter p , and the last one is executed by parameter s . The conditions shown at both choices are simple OCL expressions. Figure 3-10. Activity diagram specifying operation addService
|