UML Design Via Visual studio-sequence Diagram
This article focuses on designing a time series diagram in Visual Studio, which reads as follows:
- When to use time series diagrams
- Timing Diagram Elements Introduction
- Conditions, the use of loops in time series diagrams
- Generate sequence diagrams directly from code
First, when to use time series diagram
When you want to see the behavior of several objects within a single use case, you should use time series diagrams, which are used to demonstrate collaboration between objects (Martin Fowler).
Second, time series diagram element Introduction
First, a diagram.
The basic elements of a time series diagram are shown: Actor, Lifeline, message, return, self-invocation.
One thing to note is that the participant people:people, this is represented by the class, and the format is Name:class. If you use a class to represent the contributor name can be omitted, but the colon must be persisted. If you see someone drawing a time series diagram and find that the participant contains a colon, it means that this is a class. The other may be an ordinary abstract participant.
Third, the circulation, the condition in the time series diagram the use 1, the condition business scene, the user must inquire own bank card the expense record, first accesses the Bankservice,bankservice when receives the query request to first accesses the Securityservice to authenticate the user identity, If the identity is legitimate, directly query the consumption record, otherwise, directly return.
By right-clicking on the query message line-surround with-alt to complete the operation
2. Circulation
Business scenario, the user may have multiple cards and need to access multiple dataservice for querying.
Complete the operation by right-clicking on the-surround with-loop on the query message line
Iv. generating sequence diagrams directly from code
Sample code
How to generate: Right-click on a method.
Generated time series diagram
It's very handy to generate time-series diagrams from code. This facilitates the interpretation of your code logic like outsiders, but only if the code is to be introduced, and the encapsulation is complete.
These are the most common areas of the time series used in their work. VS, it's very handy to do it.
Visual studio-sequence Diagram