6.8 Sharing behaviour between use cases
For each use case there may be more than one scenario. In the process of requirements elicitation and specification, you may find a certain amount of common behaviour in two or more of your use cases. You may even find that an existing component can provide part or all of that common or shared behaviour. Indeed, if you do find such an existing component, this is an example of reusing requirements which is discussed more fully in MRP.
You can record the shared behaviour in a new use case and connect it to the use cases that it came from with an open-headed, dashed arrow pointing from the original use case to the new one. Think of the new use case as always being included in each of the originals. Hence the dependency arrow is labelled with the «include» stereotype. Figure 5 shows some examples from the hotel domain (rooms are not normally allocated until a guest checks in for a variety of reasons: rooms need servicing, guests extend their stay, and so forth). The «include» stereotype simply shows that a use case can contain one or more ‘sub’ use cases and that some such sub-use cases can be reused in two or more use cases.
The check for available rooms sub-use case is a shared piece of behaviour, a common scenario, which can be developed separately from other use cases. Note that this is unconditional behaviour – the check for available rooms sub-use case must be performed whenever a reservation is made or a guest checks in.
By taking out any common or shared behaviour, you can benefit from a simplification of the original use cases and make them easier to understand. There is a further benefit in terms of the internal consistency of the final requirements specification. Instead of having two or more different scenarios for a room availability check, for example, there will be just one main success scenario for the new room availability check use case as shown in Figure 5.
In addition, there is a chance to consider the reuse of existing components and also the potential identification of new components.