Responding to Debono...
> Hi all,
>
> I'm new to UML so I'm still learning about the different diagrams and
> elements. We have an existing application and I would like to draw a
> sequence diagram which shows what happens when the user wants to save
> a record in the db.
This screams of being a homework problem for a CompSci class. These
forums do not exist to do your homework for you; grinding through it is
part of the learning process. OTOH, you seem to have made a good faith
effort to solve it yourself (unless the diagram was given and the
problem is to fix it). So...
>
> These are the steps which take place:
>
> 1. User calls the Save method
> 2. The Save method calls CheckAndShowMessage which validates empty
> mandatory fields. If the method fails, a message is shown save is ended.
How is the error message shown? Wouldn't that be an interaction with the
WebAPI?
> 3. If all mandatory fields are not empty, the app makes a Post request
> to the Web Api layer. This layer simply convert the DTO received from
> the client and maps it to a domain model. This model is then pass to
> the Save method of the service layer.
What client? What DTO? I don't see a DTO argument being passed to/from
anybody.
At this ultra high level of abstraction I don't have problem with the
recursive message, but you might think about using the same trick you
used with CheckandShowMessage to indicate a different process within
WebAPI does this processing and that process would send the Save to the
BuisnessLogicLayer.
> 4. The Save method in turn calls a Validate method which validates the
> model according to business logic. If the validate method fails, an
> exception is thrown back to app (through the Web Api layer).
Is that the line at the bottom back to WebAPI? If so, is there some
other message that announces all went well?
> 5. If validation succeeds, the model is passed to the Save method of
> the Data Access Layer, which uses Entity Framework to commit the model
> to the db.
I don't see any of this on your diagram.
> 6. Before actually committing, Entity Framework performs another
> validation of the model. If validation fails, an exception is thrown.
> If validation succeeds, EF tries to commit the changes to the db.
The failure is presumably announced by WebAPI, which requires a message
to WebAPI.
If the validation succeeds, you need an interaction with a DB entity.
> 7. The db might throw an exception if the commit failed, or success if
> the commit succeeds.
That is presumably announced via WebAPI, so you need an interaction
message for that.
> 8. If commit succeeds the user gets the updated record (mapped back to
> DTO), or an exception (either from the business logic layer, EF or the
> database).
I am confused by what a 'user' is. If it is a person, wouldn't that just
be a display via WebAPI? If it is other software, then you need a
message with the updated record as an argument going back User.
I don't really understand what the 'or' clause is about. Aren't those
exceptions already handled by the previous processing? IOW, they are
manifested in error messages to the WebAPI as they are detected and the
WebAPI displays the appropriate message.
I also believe you need to think about how to indicate the application
completes. For exceptions it seems to shut down after displaying a
massage. If so, there is a problem with that. The application can't
simply close before the User reads the message. IOW, the user needs to
acknowledge the message before the application can close. You have a
similar issue for a the success of the DB store. The User has to look at
the record. In addition, there are probably other things the user might
want to do, so the application wouldn't terminate as it seems to do for
an exception. Thus there might be separate processes in App that handle
different kinds of shutdowns and they need to be invoked by a message
from somebody.
--
A man is drinking beer on his porch with his wife.
He: I love you.
She: Is that you or the beer talking?
He: It's me talking to the beer.
Life is the only flaw in an otherwise perfect nonexistence
-- Schopenhauer
Imagine how much more difficult physics would be if electrons had feelings
-- Richard Feynman
Rene Descartes went into a bar. The bartender asked if he would like a drink.
Descartes said, "I think not," and disappeared.
Entropy isn't what it used to be.
-- mwalshe89
Life is an accident of infinitesimal probability.
Thus entropy acts to extinguish it with due dilligence.
Heisenberg, Godel, and Chomsky go in to a bar.
Heisenberg: Clearly this is a joke but how do we tell if is is funny?
Godel: We can't know because we are inside the joke.
Chomsky: Of course it's funny. You are just telling it wrong.
A programmer's wife tells him, "Go to the store and get a loaf of bread.
If they have eggs, get a dozen."
The programmer returns with a dozen loaves of bread.
To do is to be (Descartes).
To be is to do (Sartre).
To be do be do (Sinatra)
-- Kurt Vonnegut
H. S. Lahman
H.la...@verizon.net
website:
http://www.hslahman.com/
software blog:
http://pathfinderpeople.blogs.com/hslahman/index.html
software book: Model Based Development, Addison-Wesley, 2011
geology book: The Evolution and Utilization of Marine Resources, MIT Press, 1972
novel: Hobsons' Dilemma, Inifinity Publishing, 2016