umldiagramuse-case

Should Login be an included use case in Logout?


I'm researching on Use Case Diagram and have some question to discuss with you. Specifically, I'm wondering about the include relationship in Use Case Diagram. When I read the document of UML organization, I see this line

All of the behavior of the included UseCase is executed at a single location in the included UseCase before execution of the including UseCase is resumed.

When I read this line, I understand that when the actor want execute the including Use Case, they must do all the included Use Case.
This make me wonder that, in case Login and Logout, if I make the Logout include Login (the following image show that), it mean that I must Login before Logout (Example, I click the Logout button and the system ask me do the Login function before it end my session)

example

I don't know whether I understand the definition of include relationship correctly.


Solution

  • Are Login && Logout use-cases?

    Login and Logout are not use cases. They are actions and these actions make sense in an activity flow.

    Use cases should have an observable result of value for a user. In other words the use case should be a reason why users may want to use the system.

    No user uses a system only to enjoy the experience of logging in or logging out. They login and logout because they have to, in order to benefit from the real use cases. So at best login and logout are constraint in a use case diagram, but not a use case.

    Moreover, use cases are not ordered. If you'd have a use case login and a real use case, nothing would guarantee that the login is performed before that other use-case, or in case of an include, at the beginning of the other use-case. So it is totally useless.

    You may have seen plenty of use-case diagram with logins. This doesn't change the above argumentation. People find it cool. Other misleadingly think that for every dialog window they need a use case. But all this is wrong.

    For every real use-case you can define an activity diagram that further describes the behavior of the use-case. In such an activity diagram, you may very accurately foresee a login action before some other things. You can even make it conditional, that login is only performed if user is not currently logged in etc.

    Does include guarantee imply an order between two use-cases?

    Let's imagine that it's not about login and logout but about two valid use-cases A - -> B.

    Then, no, it doesn't ensure sequential order between use-cases. One key reason is that it is not even certain that B would be executed at all. See Geert's explanations in the answer to this other question.

    Moreover, use-cases diagrams are not meant to present any ordering between use-cases. Taking includes to simulate an ordering is a misused of this notation. If you want to show a sequential flow, you should go for activity diagrams, not use-cases.

    Use cases are meant to represent goals. Includes are meant to identify common subgoals. Sometimes includes are used for functional decomposition. Although this is not recommended (because it leads to complex diagrams) UML is neutral about this.

    P.S. you may be interested in the article "Use cases - Yesterday, today, and tomorrow" from Ivar Jacobson, the inventor of the use case, and one of the founders of UML. It's from 2004, but he describes very well the evolution of this modeling technique until then, and explains also why low level use-case fragments (i.e. abusing extension and inclusion), and functional decomposition should best be avoided.