How to represent the flow of a real-time web application - uml

I am writing my thesis and need to represent the process flow of my application. I need to have a diagram that represents the flow of each process in my application. How do I represent an application which is meant to be "real-time". I have a shared whiteboard where whatever a user draw/write is reflected on the whiteboard of the other participants in the same room. For example if a user draw a rectangle, the coordinates and stuff will be sent to the other users for the rectangle to appear on their whiteboard. At the same time, the coordinates are stored in the database.

Well, there are obviously many solutions, but a sequence diagram can show what you need. Assuming you have two representation boards and a central instance then a change on the first board will be communicated to the central instance. This broadcasts the change to all connected other boards which in turn show the change.
Of course there are a zillion different ways to implement the scenario. But with a seuqence diagram the involved communication can be shown best.
Below picture shows an example how this can look like:
You will need to draw quite a number of those to show how the concurrent board drawings are communicated.

Related

Does my use case diagram need something more?

I have a task to make a simple information system for the functioning of a guest house. I need to make a USE CASE diagram, but I don't know if what I've done is correct, or if I need to add something, I don't know where to include the maid.
As users of the system I have put - client, receptionist, manager
As objects of the system I have put client, room, occupied rooms, employees (maids, receptionist, manager), tour agency, payment
Can you give me a hand?
Well, you are at the verge of functional decomposition. And that's not what UCs are about. They are about added value. So the bubbles contain headers describing those added values. For a hotel the basic UC would be Reserve room. (A real hotel would of course offer more added values, but for your example that's it.)
Now, the reservation is usually going along with payment. But would you consider that added value? I would not. So rather than making these UCs they are constraints (from requirements defined elsewhere). There's a lot one could talk about representing requirements and business rules, but that is far too much for a discussion here. I recommend reading Bittner/Spence about UC sythesis. It takes that book and a lot of experience to get familiar with this area.
Note that UCs are described with subject/predicate(/object) to be meaningful. Room is no UC. If you intend to show an object, use a rectangle (with object notation). That however, is in most times more confusing than helpful. Stay with actors and (real!) use cases.
Another note: the downward association from Hotel manager should rather be a generalization (open triangle instead of an arrow). And the actors usually are also shown with arms ;-)

How to represent communication protocol in UML?

In my UML model I have a system and its subcomponents that talk to each other. For Example, I have a computer and a RC robot where they talk via Bluetooth. Currently in the diagrams the flow is something like:
"Computer" triggers "setVelocity()" function of "RC car".
At this point, I want to refine the communication by saying that
computer sends "Movement" message
with velocity field is set to 100 and direction field is set to 0
which is acknowledged by RC car by sending ACK message
with message id "Movement" and sequence number X.
How do I do that?
EDIT: Clarification
Normally this is what my diagram looks like without protocol details:
But when I tried to add messages, there are at least 2 problems:
It seems like Computer first triggered the setVelocity() funciton and then sendBluetoothMessage() sequentially which are not sequential . The followings of setVelocity() are actually what happens inside that.
sendBluetoothMessage() is actually a function of Computer. But here it belongs to RC Car. (or am I wrong?) And the same things for ACK.
Thanks for the responses. You are gold!
Communication protocols in general
There are two main ways of representing the sending of a movement message between two devices:
A movement() operation on the target device, with parameters for the velocity and direction. You would typically show the exchange in a sequence diagram, with a call arrow from the sender to the receiver. The return message could just be label as ACK.
A «signal» Movement: Signals correspond to event messages. In a class diagram, they are represented like a class but with the «signal» keyword: velocity and direction would be attributes of that signal. ACK would be another signal. The classes that are able to receive the signals show it as reception (looks like an operation, but again with «signal» keyword).
In both cases, you would show the interactions of your communication protocol with an almost identical sequence diagram. But signals are meant for asynchronous communication and better reflect imho the nature of the communication. It's semantic is more suitable for your needs.
If you prefer communication diagram over interaction diagrams, the signal approach would be clearer, since communication diagrams don't show return messages.
Why signals is what you need (your edit)
With the diagrams, your edited question is much clearer. My position about the use of signals is unchanged: signals would correspond to the information exchanged between the computer and the car. So in a class diagram, you could document the «signal»Movement as having attributes id, velocity and direction:
In your sequence diagram, you'd then send and arrow with Movement (X,100,0). Signal allows to show the high level view of the protocol exchanges, without getting lost on the practical implementation details:
The implementation details could then be shown in a separate diagram. There are certainly several classes involved on the side of the computer (one diagram, the final action being some kind of sending) and on the side of the car (another diagram: how to receive and dispatch the message, and decode its content). I do not provide examples because it would very much look like your current diagram, but the send functions would probably be implemented by a communication controller.
If you try to put the protocol and its implementation in the same diagram, as in your second diagram, it gets confusing because of the lack of separation of concerns: here you say the computer is calling a send function on the car, which is not at all what you want. The reader has then difficulty to see what's really required by the protocol, and what's the implementation details. For instance, I still don't know according to your diagram, if setVelocity is supposed to directly send something to the car, or if its a preparatory step for sending the movement message with a velocity.
Last but not least, keep in mind that the sequence diagram represents just a specific scenario. If you want to formally define a protocol in UML, you'd need to create as well a protocol state machine that tells the valid succession of messages. When you use signals, you can use their name directly as state transition trigger/event.
If you really want to display this level of detail in a sequence diagram, it would look like this:
Notes:
For an asynchronous call, use an open arrowhead.
Use stacked bars to represent the call stack.
In the operation's argument list, write "argumentName=argumentValue" or just "argumentValue".
For messages for which the exact operation name is unknown or irrelevant, I use just a description without an argument list.
But be careful about which level of detail you want to show. Often, a sequence diagram becomes too complex if you display every operation in the call stack.
I was dealing with the same issue. I searched online and couldn't find something that I like. Hence I come up with this solution.
I show the communication ports on the sequence diagram and I draw communication dependent steps among port lines.
Here is a screenshot: my version of your problem.
Note: I haven't used bluetooth before so I am not sure about the acknowledge step. If this is something done automatically by the hardware( Like in the CAN Bus) I wouldn't draw it like this. I probabily wouldn't show it or I wouldn't add the function acknowledge(); and just draw the line between bluetooth port life lines.

how do i choose the right UML diagram for front end

I want to develop mobile applications, but I only focus on frontend development not on the backend.
I want to make a UML diagram, but I am confused about what to do, at this point I think I will make a use case diagram, a use case description, and an activity diagram. Do i need to add other diagram types like sequences or other? and if so what i need to make that diagram??
When drawing diagrams, you can draw them either from the entire system or just it's part perspective. Of course it is normal to use both approaches in a single project. It all depends what is your goal and what are you trying to model.
When looking at the FE, you can of course draw at least following diagrams:
Use case diagram to indicate what functions are offered by the FE. It will often be similar to UC diagram of the entire system, however it will definitely not contain the APIs exposed by the system for other systems to integrate as those are BE specific. Besides, you may have different front-ends (e.g. fat vs thin client), offering different functionalities
Activity diagram to show flow (e.g. screens' flow, e.g. per UC)
Class diagram to show data structures used by FE (they often differ to some level to the BE part, however usually are generated by the FE-BE integration layer)
Sequence diagram or Communication diagram to indicate points of integration with BE, especially in complex cases
Of course there can be much more, depending on your specific situation (e.g. timing diagram can be important in your specific case)
Having said that, take into account that you don't need to draw any diagrams. The idea of modelling is to draw those diagrams, that are needed, i.e. help grasp some ideas that may be otherwise be difficult to understand.

How to draw use case for two systems?

I am new to business analyst. Currently I have a project that needs to communicate between systems. Based on my use case, I have 2 systems and 1 data centre.
Client A can use System1 and System2. If client A makes a withdraw through System1, System 1 needs to send the details to the Data Centre.
Client A also can make a withdraw through System2 and System2 needs to send the details to the Data Centre. The Data Centre is basically the place where System1 and System2 submit their details to. Of course, it has a rule that System1 and System2 can't send and receive the details directly without the Data Centre. Can I draw it out like this?
Your use case diagram is invalid, a use case diagram doesn't show exchanges, for that use a deployment diagram for instance :
The Data Center is a secondary actor if is not part of your global system (contrarily to System1 and System2) :
If Data Center is part of your global system it doesn't not appear in the diagram because this is part of the implementation. The use cases show what must be done rather than how it is done.
If you are after showing use cases, then there is only one you named Withdraw.
Use Cases show a single added value for an actor which is dealing with the system under consideration (SUC). From a business perspective you don't care about technical details. You will put that into requirements like { ATM must be used } etc. But you're actually only after the goal behind the UC in the first place. Next would be to describe scenarios how that goal could be achieved. Only then you care about (program) technic. Please also note that verb-only use cases are not a good choice. Use a predicate-subject(-object) form, so in your case Withdraw money.
That being said (I recommend reading Bitter/Spence about use cases as always) it rather looks like you are doing a technical documentation of an existing system. You can do that by showing devices
Note the multiplicity that says there's one data center and any number of ATMs. Now what actually happens between the components can be detailed by using sequence diagrams, using interfaces and things like that. Details are too many to be shown/explained here.

Activity Diagram Synchronization Bar

I'm in the process of designing an activity diagram for a real-life card game and would like to know whether or not the use of a synchronization bar in the image attached is correct.
From my understanding, a synchronization bar can be used to separate flow into two or more activities. In my diagram, I've tried to illustrate two teams picking up a card from the set of cards they've been given. Team B's flow ends after picking up a card, this is because Team A must ask a question (found on the card) first.
Basically your diagram is correct. Drawing of cards happens concurrently. However, there is an improvement you can do. I don't know out of which reason one of the players will ask a question and the other won't. So here I assume the fastest one will start (remembering a card game from Africa where both players draw cards as fast as possible with one hand and put them somewhere; no idea of the name and rules but it was fun to play). Anyhow, here's my suggestion:
Just put the drawing in an Interruptible Region and name it after whet ever causes the one player to be the first to ask. The flow final is not necessary as to UML rules (the token is swallowed since player B's action has no outgoing flow).
I want to offer some improvements based on your explanation. (However as #ThomasKilian said, it is not so clear why one of the players will ask a question )
Case 1:
If both (TeamA and TeamB) should pick up the card and after that, you check the existence of question in selected cards: Your systems should wait for two players to pick up the card. So in this case, you should use Join Node after two pick a cards. (see my previous post about Join)
Case 2:
If the fastest Team should ask the question and there is no need to other team pick the card, there is an other improvement here:
You should use a Merge node with Decision after two pick a cards (see Merge with Decision explanation in this reference). (You can use a Merge node and after that a Decision Node too.)
So your decision is based on fastest team that pick the card. Then you should complete the model with following statement. If TeamA is fastest then TeamA should ask the question and TeamB should answer and if TeamB is fastest then TeamB should ask the question and so on.)
You can use this improvement in case 1 too (after the Join Node, you need a Decision to find the team that select the card and add above statement to your model).
Finally, If TeamA always ask the question after pick up the card and there is no need to picking the card from TeamB, there is only one improvement to use a Merge Node after two pick a cards. Consider that Merge Node input flows are alternate flows to accept single outgoing flow.

Resources