Specification of extending use case - uml

I'm trying to figure out how to specify an extending use case.
For example, suppose I have a use case Pay described in the normal flow by the point:
1. User select the product
2. User make the payment
3. System validates the payment
This flow is included in a specification table (that include actors, pre-condition, post-condition etc..)
Now I want to refer this user case in the specification of an extending use case like PayWithCreditCard without repeating all equal step; How can I do this?
In this case the only step I need to extend is step 2. and it is extended in someway like:
2.1 User choose payament with credit card
2.2 User insert credit card
2.3 User insert Pin
But how can I put this in a specification without to repeat step 1 and step 3?
Or there is another way to handle with this?

If use-case PayWithCreditCard extends use-case Pay, then Pay should identify explicitly extension-points where the extension will insert its behavior.
This is also (or especially ?) true for the tabular specification of a use-case: the specification shall list potential extension points and identify these in the flow of events. For example Spence & Bittner suggest to use curly brackets to identify the extension points (see their book Use-Case modelling, chapter 7).
In your case, this would look like this:
Use-Case: Pay
Actors: Buyer
Extension-points: Provide payment details
Validate payment
Basic flow:
1. Buyer selects the product
2. Buyer makes payment
2.1. Buyer selects the payment method
2.2. { Provide payment details }
3. System validates payment
3.1. { Validate payment }
3.2. Inform buyer that the payment was accepted
Pre-conditions: ...
The extension points would be defined in the extension. Dependeing on the selected payment method, the { validate payment } extension point could for example trigger an immediate credit card transaction with the bank, or wait for a delayed manual confirmation by an accountant that the incoming wire transfer was received.
For identifying the alternate flows, you could then use:
At { Validate payment }, if rejection or time-out: ....
It is important to be aware that an extension use-case, may need to know about the extension points of the use-case that it extends. This is different from an include relation, where the included UC is understood to be independent of the use-case that includes it.

Basically a use case shall only show added value a system under consideration delivers to one of its actors. Often people tend to start functional decomposition by misusing extends/includes. However, sometimes it's kind of useful to show variations like here when adding different payment methods that extend the payment procedure.
First of all "Pay" is no use case (it's verb only). Even "Pay product" is not a use case. I doubt the actor will see that as added value - it's more the opposite. The use case (I'd guess) is rather "Purchase product" which is a big difference. The actor wants to have the product and it's obvious that something in exchange is needed to get the product (in almost all cases that would simply be money). Now that you have this use case you want to show options (!) which you put into bubbles. These are basically no use cases per se. They just extend an existing use case. "Pay per credit card" and "Pay cash" are such extensions. (Unfortunately UML does not make a difference in the graphics for real and such pseudo use cases.)
Now, in your textual description you would have a decision at the point where you make the payment and where you would branch accordingly. Eg.
Select payment method
2.1 If credit card: Perform use case "Pay with credit card"
2.2 Else if cash: Perfom use case "Pay with cash"
Handling exceptions proves to be tricky here (in graphical as well as textual notation). So you might need to continue
If payment refused resume at ...
or the like.
A UC diagram would look like

Related

What's the difference between extension use case and parent use case?

I'm so confused about the difference between extension use case and parent use case in Use case diagram.
I would like to know when can I use the extend and when can I use the parent use case?
For example :
Print Slip extend Confirm
pay through PayPal inherits Payment.
pay through credit card inherits Payment.
What's the difference between inherits and extend ?
Image source : https://t4tutorials.com/use-case-diagrams/
All proportions kept to compare the extend and the include + generalizations is like to compare the aggregations a and b + generalizations in :
In your diagram because of the extend the behavior defined in the UC Print Slip can be inserted into the behavior defined by the UC Confirm Order
The generalizations are like they are elsewhere in UML, pay through paypal is a Payment and pay through credit card is a Payment too. The diagram indicates the UC Confirm Order includes the UC Payment or one of the two inheriting UCs. So the behavior of the UC Confirm Order contains unconditionally the behavior of the UC Payment or the behavior of the UC pay through paypal or the behavior of the UC pay through credit card.
There is an example of inheritance between UCs in the norm, see figure 18.11 page 646 in chapter 18.1.5 of formal/2017-12-05
The two blue bubbles right bottom inherit from Payment through the generalization relation. That's, well, not advisable although looking convenient. Unlike for class inheritence which is clearly defined, a UC inheritence is an open field. The UML spec uses a generalization in just one single diagram and makes absolutely no definition of what a generalization for UCs actually means!
A use case is very much in the world of prose and informal language. It (probably, since there's no definition) means that you take the description of the parent UC and replace parts of it (override) with text defined in the inheriting UC. From a context that sometimes partially works. However, paying via credit card and Paypal is very different (you know) and there's not much in common. So a better way would be to «extend» Payment with the various ways to pay. This way you have a fixed payment procedure which optionally can go the credit card or Paypal way (or even a mix if so designed).
N.B.: The above example is just a bad one. It starts functional decomposition. Use cases shall show a single unique added value a system under consideration shall bring to its actor(s). Print slip is definitely a pure function and no real added value (who needs a paper slip these days?). Selection of product just the same: what's the added value here? Calculate... is telling just that it's a function. Basically you have two use cases: Confirm order and Make payment (note that using verb+substantive is mandatory in describing a use case in the title).
As always I shall recommend Bittner/Spence as excellent read about use cases.

Should I include System's tasks/responses in UML UseCase diagram?

There is an exercise that requires us to draw a usecase diagram for a bank,
description says that a customer can make deposits and withdraw money. for that usecase scenario do i just draw
"make deposit" and "withdraw money" ? or should I <<'include'>> "update balance" function for both of them as well ?
There is a rule of gold that help me solve similar situations, hope it helps for you.
Use case definition: Series of interaction between an actor and the system to obtain added value.
So, as you can see there are interactions, basically a use case is a series of interactions.
Which interactions are for update balance? None, is just a calculation the system (as opposed to the actor) does.
Let's specify that use case under the assumption is a business use case and is a ATM.
1) Actor1 press 'start button'
2) The system show present card screen
3) Actor1 present card
4) System present menu with options...
5) Actor1 select withdraw .... ...
6) System present screen with updated
balance
7) Actor1 select ....
So this is quite visual, is not a Use case in the first place, becouse there are no interactions involved. So there is no need to check if bring added value or not. Is just an important part of one of the many interactions involved.
There are exceptions in which you may take that shortcut, such as if you want be more clear in the model or if you what to divide work based on Use cases. But IMHO that's not use case at all.
You may have 'Show balance', but it would be only one interaction, with the exception if you have options like "show on screen" or "paper-print on a ATM"
Hope it helps.
Is Update Balance a use case? Is there any added value for the actor? I guess not. It's a simple function which is performed as part of the other 2 use cases. You are trying (like most people) to perform functional decomposition. Just that two use cases share a common function does not make the function a use case. A use case is about added value which the system under consideration delivers to its actor(s). When you describe the scenario inside the use case, you might well refer to scenarios is other use cases. Each scenario step will end in an action. And you could simply refer to the action Update balance described in Make deposit when you describe Withdraw money. But the, Update balance is the result from a simple add operation. So why referring to that as a common function at all?

UML Use Case Diagram: Branching scenarios

Given the following scenario:
If the credit card is declined, the card will be ejected. Otherwise, some amount will be charged.
How do I model this in a Use Case Diagram?
As far as I understand extends, (A) extending (B) means that: "If A happens, B can happen aswell". But this doesn't quite express the above scenario since one of these events/activities has to follow.
I think my main problem is that I have not quite internalised what you express and what you leave out in a Use Case Diagram.
It's neither. The Use Case is Pay X or Buy Y or the like. This is shown in the UC bubble connected to the Actor getting that added value. Your description only shows an alternative in the flow of the UC, not another UC being included or extended. A UC is only about added value, not about functions.
As always I recommend reading Bittner/Spence.
Looks like Payment using credit card is the use case here and two scenarios are possible
1.Payment successful
2.Payment declined
These are mutually exclusive paths of the use case and dont fit into the extends or includes relationships between use cases.
Includes relationship indicates a mandatory relationship while extends indicates a optional relationship

Mapping validation and checking availability to a use case diagram

In a use case diagram for a web based hire system that I have, the following two functionality were required.
1. To validate a user's login before carrying out a payment function.
2. To check the availability of a certain tool and a time before the user is allowed to hire it.
So, for Case 1, I believe the following is correct. Is this the proper use of an include condition, or is there some other use as well?
An actor has an association with a MAKE PAYMENT use case. An include statement is drawn from the MAKE PAYMENT use case to a VALIDATE USER LOGIN use case.
For Case 2, I mapped it like this. However I feel that this isn't correct.
An actor has an association with a CHOOSE TOOL use case and a CHOOSE TIME. An include statement is drawn from them to a CHECK AVAILABILITY use case.
I think first that the two use case to choose might be more accurately depicted in a single use case, but I can't think of how the availability is to be mapped. Should it be in the specification only?
I would post diagrams, but I don't have enough reputation to.
Welcome to Stackoverflow.
Make "Validate user login" a precondition to "make payment", i.e. do not make it an extra use case. The user will not validate that he himself is logged in, the system does that for him and it's trivial. The precondition is noted in the use case description.
"choose tool" <<include>>s "choose time". That is what the user needs to do, while
"check availability" is what the system does for the user. So that goes to the use case description as well, and is not a use case of its own.
"make payment" <<extend>>s "choose tool", of course.

Is payment by credit or cash an usecase?

I'm working on an usecase diagram. The customer can pay through credit card or cash or check. I know I should mention them in diagram. But are they three separate main usecases that should be listed under usecases?
Generally, what is or is not a use case depends on the use case philosophy you are applying. The person who taught the UML class that I attended made it very clear that in his opinion, a use case can only be something that an actor wants to do.
As such, "Entering a Password" can never be a use case, because a user doesn't want to enter a password. Entering a password can just be a step within a use case, such as "Check the Account Balance".
I'd see paying as a very similar case. A customer doesn't want to pay for its own sake; a user pays because it's part of a bigger process, which is a use case.
You can model a payment use case and then create three extending use cases, one for each payment method
Only if the system you are modeling responds differently to different methods of payment.

Resources