views:

193

answers:

1

I have 3 classes: Controller, DAL and Entity. The controller calls the DAL requesting an Entity. The DAL retrieves the entity data from the DB and creates a new Entity class which is then returned to the Controller. How do I show this on a UML sequece chart (no need to show the DB)?

2nd question: how should we share UML diagrams on SO? :)

Thanks in advance

+2  A: 
   Controller       DAL               DB
        |            |                 |
        | get entity |                 |
        |----------->| get entity data |
        |            |---------------->|
        |            |< - - - - - - - -|
        |            |                 |
        |            |--               |
        |            |  |create entity |
        |            |<-               |
        |<- - - - - -|                 |

note: "Create entity" is a "self-message", so it starts from DAL's lifeline and goes back into DAL's lifeline. I just can't draw it better with characters. Forward messages are continous line, reply messages are dashed line.

EDIT: reflecting on comment, you can also show Entity's lifeline, if it's important.

   Controller       DAL               DB
        |            |                 |
        | get entity |                 |
        |----------->| get entity data |
        |            |---------------->|
        |            |< - - - - - - - -|
        |            |                 |
        |   entity   |---->Entity      |
        |<- - - - - -|       |         |
        |            |       |         |

It's useful if you want to show other calls to Entity as well.

Vizu
Nice one. You could 'dash' the lines by using spaces between the dashes (---- vs - - - -)You can add a fourth lifeline starting level with the "create entity" call, representing the lifetime of the "Entity" object.
xtofl
Would you not also added the Entity onto this diagram, showing a line from the DAL to the Entity with some time spent at the Entity to indicate object construction?
ng5000