What does the 'extend' relationship in use case diagrams mean?

 

The <<extend>> relationship allows us to remove common functionality from use cases, and specify a dependency, without making the extended use case mandatory.

 

If we use <<include>> we are stating the following:

 

 

Whilst this rigidity is good for describing reuse of functions, sometimes the system we want to model does not demand this discipline.

 

This example shows a typical example of a customer interacting with a web store. The Customer actor is able to buy a product and login online.

 

If the Customer wishes to buy a product, the <<include>> relationship stipulates that the login use case must be used. Alternatively the Customer may decide to login to the site and access other features. The association between the 'Login' use case suggests that this can happen also.

 

But all of this assumes that the web store 'knows' the Customer. What would happen if the Customer didn't have a username and password to login? How did they get it in the first place?

 

In such instances we have to provide for the fact that the Customer may want to register for an account, so that they can obtain a username and password online. So using the new use case 'Register' we get the following:

 

Now the customer is able to register their details, and use those details to login at a later date.

 

If we still think in terms of the user (Customer), we might say that this is all very well, but we don't always remember (or know) that we have to register, and its really frustrating to have to find the register bit of the application. What can we do?

 

<<extend>> relationships allow us to specify 'chunks' of functionality, that optionally extend the functionality of a base use case.

 

Our example now describes a significant user enhancement.

 

Not only can a Customer register their details directly, if they attempt to login or buy a product, and they haven't already registered, the 'Register' use case is invoked.

 

If they have already registered and they use the correct username and password, then the 'Login' use case will be satisfied and the <<extend>> relationship means that the 'Register' use case is not required.

 

'Register' extends the functionality of 'Login' if the login use case cannot be completed successfully.

 

So we can see that the <<extend>> relationship is a powerful way of changing the way that use cases operate, without making permanent changes to the base use case.