Represent sequence diagram from flow of events - uml

I have a flow of events and alternative events for a Login use case.
Basic Flow:
The actor enters his/her name and password.
The system validates the entered name and password and logs the actor into the system.
Alternative Flows:
Invalid Name/Password: If, in the Basic Flow, the actor enters an invalid name and/or password, the system displays an error message. The actor can choose to either return to the beginning of the Basic Flow or cancel the login, at which point the use case ends.
I come up with this diagram:
I was said that there is no need for an intermediate Login Screen life line. How should I design the diagram now, according to conditions given above?

This diagram is not bad. It is however somewhat confusing, because:
Login is not really a use-case, even if it's a popular practice. This has however no impact on your SD diagram itself.
Showing actors in a sequence diagram is not formally correct, even if it's a popular practice.
Login Screen is in fact a part of System, which creates a kind of implicit redundancy.
Don't worry about too much about the two first points, if this is the kind of practices that your teacher showed you.
The last point could easily be addressed:
The last lifeline could be more specific about the internals (example here), or,
Keep only two lifelines, one for the actor and one for the system. THis is in my view the better alternative when you use actors in a SD.

Related

How to determine the state in state diagram?

My system has more functions than it is shown inside the diagram but I am trying to do it based on the scenario.
My current scenario is that the librarian/admin is trying to delete a book record from the database, normal users can access the database but they cannot access the "delete book record" function.
The flow shall be like this, the user login to the system, if he/she entered the login detail correctly the account's access level will be checked and granted different levels of access based on the account type. After authenticating the account and its access level there will be several modules of function that can be chosen, such as transaction, search, database, and report module. After the user selects the database module they then choose which record they want to see/modify such as member record and book record. Then they will select the book record they wish to delete among all of the book records that are recorded in tabular form, then will click "delete" to delete the book record, the system will show a confirmation message to ensure that the user didn't accidentally delete the record they didn't mean't to. After the deletion, they can choose to do other actions but I trying to end the scenario so I put logout right after it.
I am actually quite confused about what can be considered as a "state". I know it is somekinds of condition or situation but most of the example I found online give me a feeling that it is an action.
Is the state diagram below being delivered correctly?
The narrative is about a sequential flow of actions. I've replaced some text with placeholders to demonstrate the point:
the user {action}, if {conditions} (...). After {another action} there will be (...). After {choice} {action} then {another choice} . Then {action} then {another action}, the system will {action}. After (...), {choice} but I trying to end the scenario so I put {action} right after it.
This kind of flow can be easily modelled with an activity diagram.
Your confusion and issues comes from the fact that you try to model the state diagramme based on the action, trying to describe states corresponding to actions to be performed (e.g. Login account) or performed (e.g. Account authenticated) and simply but the actions that lead from the one to the other on the state transition arrows. Your approach is understandable. Unfortunately, it leads to very complex state diagrams, and as qwerty_so explained in the comments, not even valid diagrams.
If you want to go on that way, you need to express states that are unambiguous and not to be confused with an action (e.g. user unidentified, user authenticated, ...), and keep the labels of the state transition extremely short. But a better approach would be to identify less granular states, independently of the activity diagram. Ask yourself what the system shall do when entering into a state, what the system should do while it is in the state, and what it shall do when it leaves this state. If this is unclear, then rethink about whether this is really a good state candidate. Also, think of the state transition more in terms of events that occur, rather than actions performed.
First, you have to know what you want to achieve. It seems to me you want to give an overview of the functionality of an application. Then, you decide which kind of diagram best suits this objective. Use Case Diagrams are often used to give a functional overview. Activity Diagrams are often used to depict the flows within a single use case.
If you want to use a State Machine Diagram to give an overview of the functionality of an application, you might consider having one state for every 'screen' (dialog, window, web page, whatever you call it). State X then represents the state of the application in which screen X has focus, i.e. the user currently interacts with screen X. A transition from state X to state Y represents a user action that causes screen Y to appear, while screen X either disappears or looses focus.
For example, the initial state is "Login". The second state is "Main menu". The transition from "Login" to "Main menu" has action "Press OK [user name and password are correct]", which means that the user presses the OK button and the system verifies user name and password.
For non-trivial applications, this may leads to a very complex state transition diagram. In that case, you may either split up the diagram in multiple diagrams, or use a use case diagram instead.

How do I present in a Uml use-case Diagram a toolbar

I am new to object oriented design and I wanted to do my first ever UML use case Diagram on a simple application which contains toolbar on the top left corner. The toolbar is called files and when the user clicks on it,a drop down menu is opened with options to open a slide,save slide,make new slide and exit the application.
My question is, am I doing it correct with Use-Case inheritance(Generalization) ?
This is my diagram.
I am sorry to disapoint you, but I have to tell you that this practice is just plain wrong:
From the point of view of the semantics, the use-case specialization means that Open presentation is a special form of Check file, and Save file as well, and that the actor could use them interchangeably and independently. But this cannot be what you mean: exiting a presentation is at best a sub-part of checking a file
From the point of view of the purpose, a use-case should represent a user goal. It's part of the problem space, i.e. what the user wants to achieve. It's not part of the solution space, i.e. how the user will achieve it. A toolbar is not a goal: it's a user-interface element.
From the engineering practice perspective, use-case should not be used for user-interface design. It's not my own statement, but that of Jacobson, Booch and Rumbaugh, the founding fathers of UML:
The problem is that the [use-case] descriptions often contain implicit decisions about user-interfaces. Later, when the user interface designers suggest suitable user-interfaces for the use-case , they may be limited by those decisions.
in The unified software development process, page 164
So in conclusion, it's a bad idea to start use-cases from the user-interface. It locks you into your own design and ignores the user experience. You should focus instead only on the user needs. THe same use-case could then be used whether you'll implement it using a GUI interface, a chatbot interface, or a a voice-based interface.
While drawing Use Case diagram, one thing you should focus on is, the actual meaning of it and the purpose of drawing it.
A Use Case refers to what the users in respect of their type are able to do in your System... Anything inside the boundary is what system is capable of doing or what it can provide as a service to its users.
While naming the use cases, you should only use verbs and actions, for example:
1- Login | 2- Submit a Request | 3- Update Profile Description
You should avoid any nouns in them.
There are several relationships that exist in a Use Case Diagram among use cases, and a relationship among actors and use cases of the system, And They are as follows:
Association: the only relationship that can exist between an actor and a use case; Which says the actor is initiator of this use case, or is the one who is caple of operating the use case.
In the example above, User is caple of loggin in and submitting a complaint.
Include: Use Cases can include one or more use cases. When a use case includes another use case, it means the included use case or use cases happen all the time and are part of the initial use case.
Paying fees is included, because user has to pay the fees in signing up process, it has to be done, and it's part of the baseline path of the scenario.
Extend: When a use case is not happening all the time, and is part of your alternative path ( Alternative path of the complete scnario for this use case ), the use case should be extended to the base use case.
Forget password is extended to Login use case, because it doesn't happen all the time, and it's part of a alternative path of Login scenario.
Generalization: When there exist several different ways that a use case can be performed and completed, we use generalization. The inheritent use cases should all be of the same type as the inherited use case.
Submitting a complaint can be done in several different ways, in this case, we need to seprate each use case and inherit from from the submit a complaint use case which includes paying fees, this shows that, paying fees is a part of every type of complaint which is submitted.

System sequence diagram - Can system request input from actor?

in uml - system sequence diagram, can the system ask input from the actor (see attached picture)
In my example, the scenario is: system is prompting a confirmation input from user and user is to enter in the input.
Wondering if this is the correct representation for it? I asked as usually I have done it the other way round, in which actor gives input to the system and system return the output based on input...
Preliminary remark
The practice of showing an actor in an interaction diagram is well accepted and quite common.
Nevertheless, in principle, an UML interaction diagram such as a sequence diagram, should show interactions between lifelines within an enclosing classifier:
The actor being external to your system, it’s not a part of any enclosing classifier in your system.
As a consequence, this is valid UML only if the scope of your model is larger than the IT system, i.e. you model the organisatiin that uses your IT system.
Moreover the message semantic is not clearly defined for human participants, which is exactly the issue behind your question
Be consistent
If you choose to go on with your modeling approach and consider the actor as any other classifier, then your actor instance should behave as any other object.
The flow of messages shows which object is the sender of the message and which object responds. You should consistently keep this logic, as you did in your diagram. It will be btw one of the rare place on your model where you can show that the system is at the origin of this specific interaction and not the user. (hint: don’t forget the execution specification on the lifeline: it’ll increase the readability)
If you would materialize the free-will of the actor by an arrow/message in the opposite direction, you would only increase the ambiguity further: this would give the impression that the actor is at the initiative of the message, and that the actor could send a completely different message instead. And I’m not sure that your system is designed for responding to arbitrary messages from the user.
Another alternative?
A less ambiguous alternative could be to show the interaction between a system core element and an element that represents the UI: the UI element acts as proxy for the user, but since it’s an object like any other, the interpretation of message flows is unambiguous.
This is one of the idea behind the ECB decomposition, the C being a use-case specific controller (so it links this interaction to the requirements) and the B being the UI boundary exposed to a specific kind of actors (without entering into UI details).
Short Answer: Yes
Of course, the context of this interaction cannot be the system, since the actor is outside of the system. However, it is allowed to not model the context and let the interaction be its own context. Or you could introduce a Context Class, that contains the Actor and the system. But these are only formal considerations.
More important is, whether it is useful to do this. I would say, it can be. Describing how an actor will interact with the system is one outcome of analysing the use cases. Many people will use text to describe this, but in complicated cases, UML behavior diagrams, like activity diagrams or sequence diagrams can be used.
I would reconsider using a synchroneous message here, though. Communication with a human actor is by nature asynchroneous. You never know, whether the message arrives, whether the actor understands it and whether the actor responds with the appropriate reply message.
PS: The reply message should show the name of the message it replys to, not some arbitrary text. If you want, you can show the return value after a colon (confirmationInput():Answer)
Confirmation is vague.
As a response to user input this part would be missing in your SD. Being incomplete would not be wrong. In that case you just describe that part which starts from the confirmation.
As part of some system activity (e.g. you have a control process which detects over-heating and asks the user to continue with a shut down or so) that part would not show the start of the use case being likely something like "Observe XY".
In any case using system as life line to the right seems pretty much pointless. One would be interested in which object of the system is asking for confirmation.
The question is always: what does the editor of the diagram want to tell someone else.

How Should Conditional Paths for Use-case Diagrams be Modeled?

I'm making a website where the visitor can:
View posts.
Only use regular or Facebook registration if they're not signed in.
Only login with Facebook if they've registered with Facebook.
Only use regular login or password reset if they've registered in the regular way.
Only create posts or unregister if they're authenticated.
I don't understand how I should model the different use-cases available for the visitor. Since an unregistered visitor can become registered visitor and a registered visitor can become an unregistered visitor, they can do the same thing on the site, they just take different paths.
Are these conditions important for a use-case diagram? Is it too specific to say that regular registration requires many fields to be filled in, while Facebook registration only requires the visitor to choose a username?
Can a use-case extend itself? Like if the registration fails, the visitor repeats the registration again.
Edit: I made a guess how to do the diagram:
Edit 2: Or maybe simpler like this?
As #granier said, Your second model is far better and #Thomas Kilian's points are remakable.
I want to say your mistakes and offer a new Use Case Diagram. I think there are some mistakes in your models (Logically and Practically):
Too detailed Use Case Diagram (model 1) (please see my previous post TIPS here)
Username is not Use Case.
There is not extend relationship between Login and Reset Password. (model 2)
Login associated with registered user? All users can trigger Login Use Case (even successful or not).
Wrong uses of include and extend and inheritance relationships (model 1).
Please consider my offered Use Case Diagram:
Additionally, you can add pre-conditions and post-conditions to your use case documentation. But, they do not change the Use Cases.
Your second model is far better. Use Cases generalization is not used often even in specification an exemple is provided. .
Since the user should be able to register, the actor "Unregistered User" could be removed. No ?
I use Use Cases generalization in one case only : when i want that several Use Cases get the same includes or extension.
There is nothing wrong with showing constraints as you did it. What I do is usually to create an overview diagram like your #2. And then focusing on single use cases showing just their relations to actors and requirements - and eventually constraints derived from the latter.
Don't fall in the trap of functional decomposition and avoid <<include>>/<<extend>> or even worse generalizations. Use cases are not used to decompose functional parts but synthesize them. A use case shows a single added value the system under consideration delivers to one of its actors.
Login is no use case since it has no added value. It is a constraint which you can attach to use cases.
As always: the UML specs are no good read to understand Use Case synthesis. It's written by eggheads with little business background. Look into Bittner/Spence instead.

Does a UML use can show everything the actor can do (functionality) or everything the actor wants to do (goals)?

Suppose we have a simple on-line store. Things that the user would want to achieve with the store would be:
Register (to create an account)
Browse items
Add items to basket
Checkout and pay
View account information
Edit account information
etc
However, there would be functionality that the user could initiate but wouldn't be their main goal of using the system:
Login
Logout
Select 'electronics' department
Select 'vehicles' department
Enter delivery details
etc
I would argue that things like login and logout shouldn't be in the UML use case diagram. The reason being that a user would not want to go to the on-line store just to login; they would always have another aim which would be to view / edit account information or browse and buy stuff.
Likewise, the two select 'statements' are part of the browse items use case. I wouldn't use generalisation because there could be many departments.
Finally, the enter delivery details is part of the 'checkout' or 'edit account information' use case. I would normally lump this in with the 'edit account information' use case otherwise you may as well have use cases for 'edit name', 'edit email' etc.
My main concern is if you have a very complex use case diagram it defeats the purpose of having one as it won't be easy to read.
So, my question is as follows. Is my thinking behind this correct? Is it best to only model 'real' goals in the use case diagrams or everything that the actors can initiate?
Does a UML use can show everything the actor can do (functionality) or
everything the actor wants to do (goals)?
It can be either - the UML spec isn't prescriptive on that front. Alistair Cockburn created a categorisation for Use Cases that indicates what level they focus on.
Having said that:
My main concern is if you have a very complex use case diagram it
defeats the purpose of having one as it won't be easy to read.
That's a very real risk. Personally I find I get most from UCs by focusing on the users and their goals. What value are they looking to get from the system?
Keeping it at that level prevents a "can't see the wood for the trees" situation - and also stops UCs becoming a complete, functional decomposition design.
hth.
It is not wrong to exclude some use cases from your diagram, and indeed it might be a good idea. For instance, if you are going to show your diagram to the business department, you can draw an UML model that describes the operational use cases. If you are going to hand down your diagram to the programmers, you would want to give them a complete description of what they have to implement. These are just models of your system.
When one draws a use case diagram, usually one also writes the behavior of each use case (as free-text description, pseudocode, or by using interaction diagrams).
The UML specification says that:
A use case is the specification of a set of actions performed by a system, which yields an observable result that is, typically, of value for one or more actors or other stakeholders of the system.
Login and Logout are observable to the user. While the user will not visit your site with the only goal of logging in, such use case certainly has some execution flow that you also want to describe. If you don't allow users to initiate a login by themselves, there will be use cases that include the functionality of login. A user may have also interest on logging out before leaving the site, so that no session data will remain stored in his computer.
Select 'electronics' department, Select 'vehicles' department... Why not just Select department (I suppose that they are not too different).
I would draw this and other use cases, as long as they are relevant to the model.

Resources