2

I have an actor for - just an example - web site, called "Visitor" in an UML2 sequence diagram. This actor interacts with a boundary object, sends credentials and gets back a session token. When this is done, I would like to promote this actor to "Authenticated User".

I would like to keep "Visitor" and "Authenticated User" as they represent different roles and have different interactions with the system. (Visitor's use case is not a subset of "Authenticated User"'s, as Visitor gets ads, etc.)

Now, I can create a separate LifeLine for "Authenticated User" and create a "Create" message for it and a "Destroy" message for "Visitor" at the proper place, but this really seems awkward.

I can also create a "<< promote >>" stereotype but what is the generally accepted method of doing this?

TFuto
  • 1,361
  • 15
  • 33

4 Answers4

2

Think of it like when the "Visitor" promotes to the "Authenticated User" then somewhere in the system actually an avatar gets born. It is not the "Visitor" traveling in the system, it is his/her avatar. So creating another actor object with its own lifeline seems ok to me.

(Certainly you can then implement the two different "states" of existence using a simple boolean switch in a generic User class but it is not what you asked for..)

I would probably use

or something very similar

Community
  • 1
  • 1
xmojmr
  • 8,073
  • 5
  • 31
  • 54
  • Agree, "Actors" can be also displayed as Objects / Classes, specially when inheritance is implied – umlcat Dec 11 '14 at 20:03
0

If you model them as different actor (and so different classifiers) then you can move from one to another. If you are a certain type you cannot change that type during your lifetime. So in that case you have no choice but to start with a new "Authenticated User"

Stereotypes belong in the meta-world. So unless you are making your own UML Profile to support your modelling method, you shouldn't be touching stereotypes.

Geert Bellekens
  • 12,788
  • 2
  • 23
  • 50
0

Executable UML (nee Shlaer-Mellor) supports the concept of subtype migration. However, most object oriented languages don't. While it is a useful concept, you will need multiple lines of code to implement this. I would suggest a "copy" constructor that performs the migration. See the article at UML Subtype Migration.

The ORM modeling technique has examples in Information Modeling and Relational Databases By Terry Halpin, Tony Morgan Found in Google Books.

Bruce
  • 2,230
  • 18
  • 34
0

Short Quick Answer

Apply "stereotypes" and "notes" to extend U.M.L. Diagrams

Long Boring Extended Answer

You question is a valid one.

There is not a general standard for this at the "Sequence Diagram (s)", directly.

Indirectly, I have seen many "Sequence Diagram (s)", like this case, split this into 2 or more diagrams, where there is a diagram for the "Visitor registers into Website", and another diagram, "Visitor becomes User, by loggin into Website", that extends the first diagram.

Remember, that many "Sequence Diagram (s)" are represented by a small "Use Case Diagram", with "Actor (s)", and both "Actor (s)" and "Use Case Diagram (s)" can use the <<extend>> stereotype.

An example of an "User" Actor being extended by another Actor, [without Use Case (s) ], could be something like this:

..................................
....(o)...................(o).....
.....|.....................|......
..---+---...............---+---...
.....|......<<extend>>.....|......
.....|<--------------------|......
.....^.....................^......
..../.\.................../.\.....
.../...\................./...\....
..................................
..Visitor.................User....
..................................

An example of a Use Case being extended by another Use Case, [without Actor (s) ], could be something like this:

....................................................................
......------------------.....................------------------.....
..../...................\................../...................\....
.../.....................\................/.....................\...
..|......Visitor..........|..<<extend>>..|......Visitor..........|..
..|......Arrives To.......|<-------------|......Registers........|..
..|......Website..........|..............|......Into Website.....|..
...\...................../................\...................../...
....\.................../..................\.................../....
.....-------------------....................-------------------.....
....................................................................

And, this situation is very common, and, frequent, to be consider a "defacto", standard.

Is not bad, and is not an error, that you jump straight ahead to the "Sequence Diagram (s)".

Yet, maybe you should:

[1] Add a "Visitor arrives to Website" Use Case diagram, with an actor called "Visitor"

..............................................
....................-------------------.......
.................../....................\.....
....(o).........../......................\....
.....|.........../........................\...
..---+---.......|........Visitor...........|..
.....|..........|........Arrives To........|..
.....|.=========|........Website...........|..
.....^..........|..........................|..
..../.\.........|..........................|..
.../...\.........\......................../...
..................\....................../....
..Visitor..........\..................../.....
....................--------------------......
..............................................

[2] Add the related "Visitor becomes User, by registering into Website" Use Case diagram, with an actor called "Visitor"

.........................................................
....................-------------------..................
.................../....................\................
....(o).........../......................\...............
.....|.........../........................\..............
..---+---.......|......Visitor.............|.............
.....|..........|......becomes.User........|.............
.....|.=========|......by.registering......|.............
.....^..........|......Into.Website........|.............
..../.\.........|..........................|.............
.../...\.........\......................../..............
..................\....................../...............
...Visitor.........\..................../................
....................--------------------.................
.........................................................

[3] Add the related "User logs into Website" Use Case diagram, with an actor called "User"

.........................................................   
....................-------------------..................
.................../....................\................
....(o).........../......................\...............
.....|.........../........................\..............
..---+---.......|.......User Logs..........|.............
.....|..........|........Into.Website......|.............
.....|.=========|..........................|.............
.....^..........|..........................|.............
..../.\.........|..........................|.............
.../...\.........\......................../..............
..................\....................../...............
....User...........\..................../................
....................-------------------..................
.........................................................

[4] Merge the previous diagrams, into a single one, with the <<extends>> stereotype

.....................................................................................
....................-------------------..............................................
.................../....................\............................................
....(o).........../......................\...........................................
.....|.........../........................\..........................................
..---+---.......|........Visitor...........|.........................................
.....|..........|........Arrives To........|.........................................
.....|.=========|........Website...........|.........................................
.....^..........|..........................|.........................................
..../.\.........|..........................|.........................................
.../...\.........\......................../..........................................
..................\....................../...........................................
..Visitor..........\..................../............................................
....................--------------------.............................................
.............................^.......................................................
.............................|.......................................................
.............................|..<<extends>>..........................................
.............................|.......................................................
....................-------------------..............................................
.................../....................\............................................
....(o).........../......................\...........................................
.....|.........../........................\..........................................
..---+---.......|......Visitor.............|.........................................
.....|..........|......becomes.User........|.........................................
.....|.=========|......by.registering......|.........................................
.....^..........|......Into.Website........|.........................................
..../.\.........|..........................|.........................................
.../...\.........\......................../..........................................
..................\......................O...........................................
...Visitor.........\..................../.\..........................................
.....^..............--------------------...\....+------------------------------+--+..
.....|...................^..................\...| "Visitor" becomes "User",     \ |..
.....|...................|...................\..| by registering,                \|..
.....|..<<extends>>......|..<<extends>>......+--O into website                    +..
.....|...................|................../...|                                 |..
.....|..............-------------------..../....+---------------------------------+..
.....|............./....................\./..........................................
....(o).........../......................O...........................................
.....|.........../........................\..........................................
..---+---.......|.....User Logs............|.........................................
.....|..........|......Into.Website........|.........................................
.....|.=========|..........................|.........................................
.....^..........|..........................|.........................................
..../.\.........|..........................|.........................................
.../...\.........\......................../..........................................
..................\....................../...........................................
....User...........\..................../............................................
....................-------------------..............................................
.....................................................................................

[5] Describe each nested Use Case diagrams with its corresponding Sequence diagram (s)

[6] Add notes to each nested Use Case diagrams, indicating there is a Sequence diagram

...................................................................
..................+------------------------------+--+..............
..Visitor.........|  "Visitor" arrives            \ |..............
..................|  to website                    \|..............
....(o)..O--------O                                 +..............
..---+---.........|                                 |..............
.....|............+---------------------------------+..............
.....|.............................................................
.....^..............+---------+..........+-----------+.............
..../.\.............| Website |..........|  Database |.............
.../...\............+----+----+..........+-----+-----+.............
.....|...................|.....................|...................
....+-+-+..............+-+-+.................+-+-+.................
....|   |..Arrives.....|   |..DoSomething()..|   |..DoSomething()..
....|   +=============>+   +---------------->+   +---+.............
....|   |..............|   |.................|   |...|.............
....|   +<-------------+   +<----------------+   +<--+............. 
....|   |..............|   |.................|   |.................
....+-+-+..............+-+-+.................+-+-+.................
...................................................................

[7] Add notes to each Sequence diagram, indicating, it describes a Use Case diagram

.....................................................................................
....................-------------------..............................................
.................../....................\............................................
....(o).........../......................\...........................................
.....|.........../........................\..........................................
..---+---.......|........Visitor...........|....+------------------------------+--+..
.....|..........|........Arrives To........|....|                               \ |..
.....|.=========|........Website...........|....| Detailed by corresponding      \|..
.....^..........|..........................O----O Sequence Diagram                +..
..../.\.........|..........................|....|                                 |..
.../...\.........\......................../.....+---------------------------------+..
..................\....................../...........................................
..Visitor..........\..................../............................................
....................--------------------.............................................
.............................^.......................................................
.............................|.......................................................
.............................|..<<extends>>..........................................
.............................|.......................................................
....................-------------------..............................................
.................../....................\............................................
....(o).........../......................\...........................................
.....|.........../........................\..........................................
..---+---.......|......Visitor.............|....+------------------------------+--+..
.....|..........|......becomes.User........|....|                               \ |..
.....|.=========|......by.registering......|....| Detailed by corresponding      \|..
.....^..........|......into.Website........O----O Sequence Diagram                +..
..../.\.........|..........................|....|                                 |..
.../...\.........\......................../.....+---------------------------------+..
..................\......................O...........................................
...Visitor.........\..................../.\..........................................
.....^..............--------------------...\....+------------------------------+--+..
.....|...................^..................\...| "Visitor" becomes "User",     \ |..
.....|...................|...................\..| by registering,                \|..
.....|..<<extends>>......|..<<extends>>......+--O into website                    +..
.....|...................|................../...|                                 |..
.....|..............-------------------..../....+---------------------------------+..
.....|............./....................\./..........................................
....(o).........../......................O...........................................
.....|.........../........................\..........................................
..---+---.......|.....User Logs............|....+------------------------------+--+..
.....|..........|......into.Website........|....|                               \ |..
.....|.=========|..........................|....| Detailed by corresponding      \|..
.....^..........|..........................O----O Sequence Diagram                +..
..../.\.........|..........................|....|                                 |..
.../...\.........\......................../.....+---------------------------------+..
..................\....................../...........................................
....User...........\..................../............................................
....................-------------------..............................................
.....................................................................................

[EDIT: Added several ASCII U.M.L. Diagrams]

Done.

umlcat
  • 4,091
  • 3
  • 19
  • 29
  • Where is your famous asciiart? – xmojmr Dec 11 '14 at 07:32
  • @xmojmr Sorry, I'll add the UML Charts later – umlcat Dec 11 '14 at 18:22
  • Nice article and nice huge charts (you have my upvote already). But I have not seen the `<>` stereotype to be used between two actors, until today. So far it always looked like normal generalization link, like in this picture: http://stackoverflow.com/a/15019079/2626313. Are you sure it is syntactically correct? – xmojmr Dec 11 '14 at 20:41
  • 1
    @xmojmr Yes, I have seen them before, but, I have to check and remember the links. I also remember several UML proposals to split "Actor (s)" into Declarations and "Roles", similar to this case – umlcat Dec 11 '14 at 22:04