Project Life Cycle  «Prev  Next»
Lesson 8 Extends stereotype and generalization
ObjectiveIdentify and model the Extends stereotype and generalization of use cases

Extends Stereotype and Generalization

Within any given system, there are usually a number of different ways to accomplish a task.
The UML provides two ways to model these variations: the Extends stereotype and generalization.
Question: What is the difference between the extends stereotype and generalization in UML? In UML, the 'extends' stereotype and the 'generalization' relationship are both used to model relationships between classes, but they represent different types of relationships. The 'extends' stereotype is used to indicate that a use case (or a specific behavior within a use case) may be optionally added to another use case. This means that the extended use case is not necessary for the base use case to be completed successfully, but it may provide additional functionality.
In UML notation, the 'extends' stereotype is depicted as a dashed arrow with the '«extend»' label pointing from the extending use case to the extended use case. On the other hand, the 'generalization' relationship is used to model an inheritance relationship between classes. This means that one class (the subclass) inherits attributes and behaviors from another class (the superclass). In UML notation, the 'generalization' relationship is depicted as a solid line with a hollow triangle pointing from the subclass to the superclass.
In summary, the 'extends' stereotype is used to indicate optional behavior that can be added to a use case, while the 'generalization' relationship is used to model an inheritance relationship between classes.

Extends Dependency Stereotype

Some processes include optional behavior or behavior that is used only in specific circumstances. To include the flow of events in the main flow would unduly confuse the use case narrative. For example, some checking accounts can be attached to a line of credit or savings account. If the client attempts to withdraw funds beyond the checking account balance, extra logic is needed to access the funds in the attached account. You can separate this extra flow of events into its own use case. When it is needed, it can be referenced in the use case narrative.

Transfer Funds extends Withdraw Funds
1) Transfer Funds extends Withdraw Funds
  1. Use the dependency (dashed) arrow from the new or extending use case to the use case that is being extended
  2. Place the <<extends>> stereotype on the arrow.

Generalization

Generalization works the same in use case modeling as in object modeling. Both actors and use cases may be generalized. The specialized form of actor or use case inherits all the properties of the base actor or use case. The specialized element may then override or add to the properties of the base definition. Use case diagrams use the same notation as class diagrams to show generalization. Draw a line from the specialized element to the base or generalized element. Place a triangle at the base element end of the line with the apex touching the base element.

Generalization example
For example a perferred customer is a type of customer. A preferred customer actor may replace a customer actor anywhere a customer actor is used (the rule of substitution)
  1. Preferred Customer inherits from Customer
  2. a) Direct Deposit Funds and b) Deposit from other Account inherits from Deposit Funds

Include Extends Generalize - Quiz

Click the Quiz link below to take a short multiple-choice quiz on the Include and Extend stereotypes and generalization.
Include Extends Generalize - Quiz

Extends Dependency Stereotype - Exercise

Click the Exercise link below to update the course project use case diagram.
Extends Dependency Stereotype - Exercise