Use Case Diagram Tutorial

Use Case Basics:

Use Cases for beginners Writing Effective Use Case

Modeling Use Case Elements:


Use Case Diagram for an ATM:


The ”include” Dependency:

What is Include in Use Case:

Include is used to extract use case fragments that are duplicated in multiple use cases. The included use case cannot stand alone and the original use case is not complete without the included one. This should be used sparingly an only in cases where the duplication is significant and exists by design (rather than by coincidence). For example, the flow of events that occurs at the beginning of every ATM use case (when the user puts in their ATM card, enters their PIN, and is shown the main menu) would be a good candidate for an include. A base use case is dependent on the included use case(s); without it/them the base use case is incomplete as the included use case(s) represent sub-sequences of the interaction that may happen always OR sometimes. (This is contrary to popular misconception about this, what your use case suggests always happens in the main scenario and sometimes happens in alternate flows simply depends on what you choose as your main scenario; use cases can easily be restructured to represent a different flow as the main scenario and this should not matter). In the best practice of one way dependency the base use case knows about (and refers to) the included use case, but the included use case shouldn’t ‘know’ about the base use case. This is why included use cases can be: a) base use cases in their own right and b) shared by a number of base use cases.

The ”extend” Dependency:

What is Extend in Use Case:

Extend is used when a use case adds steps to another first class use case. For example, imagine “Withdraw Cash” is a use case of an ATM machine. “Assess Fee” would extend Withdraw Cash and describe the conditional “extension point” that is instantiated when the ATM user doesn’t bank at the ATM’s owning institution. Notice that the basic “Withdraw Cash” use case stands on its own, without the extension. The extending use case is dependent on the base use case; it literally extends the behavior described by the base use case. The base use case should be a fully functional use case in its own right (‘includes included of course) without the extending use case’s additional functionality. Extending use cases can be used in several situations:
  • The base use case represents the “must have” functionality of a project while the extending use case represents optional (should/could/want) behavior. This is where the term optional is relevant – optional whether to build/deliver rather than optional whether it sometimes runs as part of the base use case sequence.
  • In phase 1 you can deliver the base use case which meets the requirements at that point, and phase 2 will add additional functionality described by the extending use case. This can contain sequences that are always or sometimes performed after phase 2 is delivered (again contrary to popular misconception).
  • It can be used to extract out sub sequences of the base use case, especially when they represent ‘exceptional’ complex behavior with its own alternative flows.
One important aspect to consider is that the extending use case can ‘insert’ behavior in several places in the base use case’s flow, not just in a single place as an included use case does. For this reason it is highly unlikely that an extending use case will be suitable to extend more than one base use case. As to dependency, the extending use case is dependent on the base use case and is again a one way dependency, i.e. the base use case doesn’t need any reference to the extending use case in the sequence. That doesn’t mean you can’t demonstrate the extension points or add a x-ref to the extending use case elsewhere in the template; but the base use case must be able to work without the extending use case.

Generalization:


Putting It All Together: