Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I am trying to draw a UML use-case diagram to model requirements for a software project.

The two requirements I have issue to model are:

  1. TravelAgent creates a booking for a [old] client who is requesting a home.

  2. When a new client wishes to make a booking, the TravelAgent register him/her to the system before doing the booking.

I have two approaches to model these requirements:

  1. Modeling the first use-case as a sub-procedure of the second use-case (Figure 1).
  2. Extending the first use-case (Figure 2).

Both approach imply that the first use-case could be perform independently, but when the second use-case is executed, the first one MUST be executed too.

Are they actually same and both correct?

P.S. As another question, since the NewClient converts to a Client after the registration, should I show the NewClient as subclass of Client or something?

Figure 1 Figure 1

Figure 2 Figure 2

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

Beware that extend is used in UML quite differently than in e.g. Java.

Your diagrams are probably not expressing what you would like them to. You used the generalization relationship (the arrow with a hollow triangle). This implies a "is a" relationship. But clearly neither is "Register a client" a case of "Create a booking" nor the other way round.

The correct way to indicate a "include" or "extend" relationship is with a dashed line e.g. - - - > . Now the difference between the two is the following. Suppose A includes B. This means that whenever somebody does A she will do B too. On the other hand, if A extends B, than whenever somebody does A, B has nothing to do with it. But if you do B, you might do A additionally during the course of B. You should specify a condition under which A actually extends B.

In your case you could actually use both as long as you indicate in the condition of the extends version that this depends on the customer being new.

About your modeling of the new client. I do not believe that there is much value in expressing the difference between the two here. BTW "subclassing" is not the correct term, it is (again) generalization. Adding such a generalization implies that every new customer is a customer and can do whatever a regular customer can do. I cannot decide if this is what you want.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.