Here is my sample shown also on picture below
#startuml
participant "Client" as C
participant "Server" as S
participant "Third Party" as 3PT
C -> S++: request money
S -> S: do I know you?
S -> 3PT++: give me money for client
return here you have money
S ->> S++ #005500: compute usage
S ->> 3PT: notify about computation details
deactivate S
return money
#enduml
Is it possible in PlantUml sequence diagram somehow define the lifeline for async operation to end after lifeline from which it was started? So in this case I'd like to finish the compute usage in green lifeline after return from request money lifeline. By that I would say that compute usage is asynchronous operation and can end at any time. Don't know whether this is valid from UML point of view though.
As I know there is no way for a reflexive message like S ->> S++:... or S ->> S:... to start from an OccurrenceSpecification and finish to an other (and that for a lot of tools, including mine), so the only way seems to represent the Server two times. To clearly indicate it is the same server you can indicate the name the instance, for instance (naming all instances):
#startuml
participant "c:Client" as C
participant "s:Server" as S
participant "tp:Third Party" as 3PT
participant "s:Server" as Sagain
C -> S++: request money
S -> S: do I know you?
S -> 3PT++: give me money for client
return here you have money
S ->> Sagain++: compute usage
C <-- S: money
deactivate S
Sagain ->> 3PT: notify about computation details
deactivate Sagain
#enduml
The norm says §17.12.17.1 lifelines represent only one interacting entity, but an entity can be presented by several lifelines :
norm § 17.12.17.4 (association ends of Lifeline)
represents : ConnectableElement [0..1] (opposite A_represents_lifeline::lifeline)
References the ConnectableElement within the classifier that contains the enclosing interaction
norm § 17.13.31.2 (Owned Ends of A_represents_lifeline)
lifeline : Lifeline [0..*] (opposite Lifeline::represents)
(notice the multiplicity 0..*)
Out of your problem it is strange to see the message do I know you? alone without consequences depending on the result, PlantUML manages combined fragment alt to indicate alternatives
Related
I want to create a uml diagram that can represent sentences as the one below:
"On 21/03/2020, baker A purchased from the flour company B 20 Kg of type AAA flour for 1.20 euros per kg, that he later used to produce 70 pieces of bread that he then sold to different costumers of his shop on 23/03/2020 with the price of 1.10 euro per piece."
Below you can see my first thoughts. This is quite general, I haven't added attributes yet. My problem is that I'm not sure how to represent that 2 different people make the transaction, the buyer (ie baker A) and the seller(company B), and how to show that someone (ie baker A) can be both a buyer(ie he buys from B) and a seller (ie A sells bread to costumers):
First notice that a UML Class Diagram can only represent sentence types, but not a specific sentence, which could, however, be represented by what is called an 'Object Diagram'.
How to represent that 2 different people make the transaction, the
buyer (ie baker A) and the seller(company B)
You have already represented this in your second class diagram with the associations between Buyer/Seller and Transaction, but since you've also defined Buyer and Seller to form an overlapping segmentation of Trader, you need to attach a constraint "buyer is distinct from seller" to your Transaction class.
For completeness, you should also add multiplicities at both ends of these two one-to-many associations ( a "1" at the Buyer/Seller end, and a "*" at the Transaction end).
How to show that someone (ie baker A) can be both a buyer(ie he buys
from B) and a seller (ie A sells bread to costumers)
This is already possible according to your second diagram where every Buyer and Seller is a Trader, and this segmentation is overlapping (by default), and therefore a trader can be a buyer in one transaction and a seller in another one.
There are many more diagram types than class diagrams. Do you have any constraint that it must only be one diagram? If so, why? Each diagram type focuses on a particular view onto the system under design, so they go together. It is not the purpose of UML to reflect all information in just one diagram. For example, try to complement your diagram with an acitivity diagram or sequence diagram. You'll find it helpful.
how to show that someone (ie baker A) can be both a buyer(ie he buys from B) and a seller (ie A sells bread to costumers)
You did that already with the abstraction of the Trader.
I'm not sure how to represent that 2 different people make the transaction, the buyer (ie baker A) and the seller(company B)
Just add them to Transaction as attributes.
Hint: The relation "Unit / Price / Product" is not UML compliant.
I want to create a UML sequence diagram (see below) where I have an alt frame with two conditions (status equals foo or bar). In the foo case I send a synchronous message from A to B, get the return message and then proceed with the rest of the sequence diagram (call spam()). In the bar case I send another synchronous message from A to C to but there will be no return. I'm trying to model a function call in SW which doesn't return (it blocks forever on a semaphore) so in that case I will never proceed to spam(). Can this be expressed in a sequence diagram? I can exclude the return value but that would only tell me that there is no return value, not that there is no return at all. Can this only be expressed by splitting the diagram in two and handle the conditions separately or is there a better diagram to express this?
You can place a duration constraint between the call and the return.
Under normal circumstances, such a constraint would be represented by an integer followed by a time unit, such as "10 seconds" or by a range such as "[1;10) seconds".
Your question is interesting in that you want to model infinity.
I would go about doing it like this:
However I must admit that I am unsure if my formulation violates OMG's UML 2.5 standard. I did not find anything in the standard which explicitly disallows using 'infinity' as a time unit; the standard does mention that the time should be relative.
I have a use case diagram, which has three Actors: User, Librarian and Staff.
The Staff and Librarian actors are specializations of the User actor, and in the Use Case diagram they each have some extended use cases associated only to them.
In the sequence diagram, how do I show that the Librarian actor is a specialization of the User actor?
Can the specialized actors (Librarian and Staff) have their own timelines in the Sequence diagram?
Do I have to show a timeline for the generalized actor, even if it has no extra uses cases or actions over its specializations?
Is it OK to re-arrange the Timelines of a sequence diagram once it has been extracted out into its own diagram, using an Interaction Use box in the main sequence diagram?
In the sequence diagram, how do I show that the Librarian actor is a specialization of the User actor?
There's no way (as far as I know). You can show this relationship in UML Use Case Diagram and even better in UML Class Diagram
Can the specialized actors (Librarian and Staff) have their own timelines in the Sequence diagram?
Yes, assuming they both play a role and interact in the scenario which the Sequence Diagram captures
Do I have to show a timeline for the generalized actor, even if it has no extra uses cases or actions over its specializations?
No, you don't have to show formally correct but otherwise useless artifacts in your diagrams, unless a followup code generation (or MDA) tool forces you to do so
Is it OK to re-arrange the Timelines of a sequence diagram once it has been extracted out into its own diagram, using an Interaction Use box in the main sequence diagram?
I'm not sure, but probably yes, if you keep binding of inputs and outputs and information identifying the lifeline clear and valid. Some articles where the correct answer might be hidden:
Source: uml-diagrams.org: UML Sequence Diagrams → Interaction Use
...One constraint imposed by UML specification that is sometimes difficult to follow is that the interaction use must cover all involved lifelines represented on the enclosing interaction. This means that all those lifelines should be somehow located near each other. If we have another interaction use on the same diagram it could be very tricky to rearrange all involved lifelines as required by UML
Source: www.omg.org/spec/UML/2.5/Beta2
17.7 Interaction Uses → Semantics → Part Decompositions
Decomposition of a lifeline within one Interaction by an Interaction (owned by the type of the Lifeline’s associated ConnectableElement), is interpreted exactly as an InteractionUse. The messages that go into (or go out from) the decomposed lifeline are interpreted as actual gates that are matched by corresponding formal gates on the decomposition.
As the decomposed Lifeline is interpreted as an InteractionUse, the semantics of a PartDecomposition is the semantics of the Interaction referenced by the decomposition where the gates and parameters have been matched...
17.7 Interaction Uses → Notation → PartDecomposition
PartDecomposition is designated by a referencing clause in the head of the Lifeline as can be seen in the notation sub clause 17.3.4 (Lifeline) (see also Figure 17.21).
If the part decomposition is denoted inline under the decomposed lifeline and the decomposition clause is “strict,” this indicates that the constructs on all sub lifelines within the inline decomposition are ordered in strict sequence (see 17.6.4 (Strict interactionOperator)...
Figure 17.21 PartDecomposition - the decomposed part
...
I am trying to model a vending machine program using alloy . I wish to create a model in which I could insert some money and provide the machine a selection option for an item and it would provide me the same and in case the money supplied is less then nothing would be provided .
Here I am trying to input a coin along with a button as input and it should return the desired item from the vending machine provided the value ie. amount assigned to each item is provided as input. So here button a should require ten Rs, button b requires 5 rs, c requires 1 and d requires 2 . The op instance is the item returned once the money required is inserted. opc is the balance amount of coins to be returned. ip is input button and x is money input . How can I provide an instance such that it intakes multiple coins as input and also if the amount is greater than the item cost then it should return a no of coins back. If I could get some help it'll be greatly appreciated.
If I were you, I'd proceed by asking myself what kinds of entities I care about; you've done that (signatures for coins and items -- do you also need some notion of a customer?).
Next, I'd ask myself what constitutes a legal state for the system -- sometimes it helps to think about it backwards by asking what would constitute an illegal or unacceptable state.
Then I'd try to define operations -- you've already mentioned insertion of money and selection of an item -- as transitions from one legal state of the system to the next.
At each stage I'd use the Analyzer to examine instances of the model and see whether what I'd done so far makes sense. One example of this pattern of defining entities, states, and state transitions in that order is given in the Whirlwind Tour chapter of Daniel Jackson's Software Abstractions -- if you have access to that book, you will find it helpful to review that chapter.
Good luck!
module vending_machines
open util /ordering[Event]
fun fst:Event{ordering/first}
fun nxt:Event->Event{ordering/next}
fun upto[e:Event]:set Event{prevs[e]+e}
abstract sig Event{}
sig Coin extends Event{}
pred no_vendor_loss[product:set (Event-Coin)]
{
all e:Event | let pfx=upto[e] | #(product&pfx)<=#(Coin&pfx)
Lets say i have Use Case A (Cancel Consultation),B (Destroy Patient Image) and Actor C (Patient).
Use Case A includes Use Case B, and Actor C triggers Use Case A to happens. My question is, do i need to add a <> from the Actor C to Use Case B ? I was thinking ,Use Case B happens only if Use Case A fires, which means Actor C ONLY triggers Use Case A.
Not so sure that if Use Case A includes Use Case B, and Use Case A triggers by Actor C, therefore Use Case A and B has the primary actor of Actor C ???
From description I'd say you don't need a relation between Actor C & Use Case B.
Rationale: A link between an Actor and a Use Case should represent a meaningful unit of value to the Actor. From your description, "Cancel Consultation" is that meaningful unit of value; it's what the Patient sets out to accomplish.
Destroying the image is a necessary requirement of cancelling the consultation. However - at least in this example - the Patient doesn't set out just to destroy the image. Hence no link between Patient & Destroy Image.
Of course: that could change. As you explore the domain, you might find a scenario in which it's valid for a Patient (or perhaps another Actor) to destroy an image. Perhaps a Radiographer would destroy an image if it didn't focus correctly (dunno, I'm making this up).
All comes back to the User intent. You should link Actors with Use Cases that capture their goals, not sub-steps within those goals.
hth.