1
votes

I'm new to UML but I'm tasked to draw some UML diagrams that describe some complex parts of our system.

One of these parts is the saving of data in the db, and the steps said data goes through before it can actually be saved.

These are roughly the steps involved:

  1. User wants to save
  2. App validates that all mandatory fields have values set
  3. If not valid, app shows a message. If valid, app sends a post request
  4. The controller maps the dto to the domain model object and passes it to the service layer
  5. Service layer validates the model according to business rules. If not valid, throws a validation exception
  6. If valid, model moves down to the data access layer, where EF is used to commit the changes to the db
  7. On trying to commit, EF might throw a validation exception (mapping) or database exception (bubbled up from the db itself)
  8. If commit succeeds, the model is passed to the controller which maps it back to its dto counterpart and displayed to the user
  9. If validation or database exception is thrown, these are displayed to the user

So far this is what I came up with:

Sequence Diagram

Is this good enough to display the above steps or might there be improvements to the diagram?

2

2 Answers

1
votes

If you put something on a sequence diagram then it means it has to be applied unconditionally (i.e. on each run you need to have ValidationErrors message and DatabaseErrors message which probably isn't something you want). Actually you don't have a positive path on your diagram (the "OK" from DataAccess Layer comes after receiving 2 Exceptions, same for return from Database to Entity Framework . Moreover OccurenceEvent should always start at the message/signal reception. On your diagram some of those begin without any actual triggers.

Read about Fragments, especially Combined Fragments (17.6/17.6.3.3 in UML specification, however I suggest some more user friendly type of documentation, like uml-diagrams.org or some books about UML).

Also I'm not sure if SO is the best place for this type of questions. It should rather be put on some discussion panel (forum) as you don't have a specific problem, but would rather like to validate your diagram.

0
votes

In sequence diagrams we show the interaction between classes or objects. before drawing sequence diagram we need to identify the classes and their methods(behaviours). In sequence diagrams there are three type of classes.

  1. boundry class
  2. control class
  3. Entity class

Boundry classes represents the views of the system(user interfaces). Entity classes show the table of the database(Entities) Control classes stay between boundry classes and Entity classes.And passes messages among them.

  • In Your diagram I think database should not be a class name. So you can't define it in the sequence diagram.(you can define related class for particular table)
  • you need to specify the data you are passing to other classes through a method. for example:

    save(user_name,age)

  • You can display user as a actor rather than displaying as a class.

  • current diagram doesn't show the conditions of the system(if else condition).You can use "alt" to show the conditions.

  • when you are passing messages between classes the method name should have been defined in the receiving class.