Accumulate Kuibu, Poly stream-------about UML time series diagram

Source: Internet
Author: User

The existence of UML time series diagram

In the previous article, the UML class diagram was recorded, and the class diagram was used to describe the classes needed in the code and the relationship between them, and the whole program framework was displayed in front of us, like a painting, there are some people with water in the mountains.

A photo can only freeze at that time of the good, and so on, but often not rejoice, but melancholy and lost, those who dwell on, after all, or follow the time, even reluctantly, can only be intoxicated in memory.

If the class diagram is a picture, that memory is a picture of the time series, passing, may also miss, laugh, may also cry, but no matter what, we let the world a little change, a little moving up.

If the class diagram is a blueprint that has been planned, then the timing diagram is a record of those dreams come true or history.

The representation method of UML time series diagram

Let's first look at an example:

So we have a general understanding of the timing diagram, and then also found the time series diagram commonly used objects, lifelines, activation period and message, and so on, yes, here is no longer a class, but the object, a real instance.

This representation is the most obvious, the object name: The class name makes it easy to know B myb=new B (); However, it has two other ways: direct use: ": Class name" Because we don't need to know the object name of the specific definition, and "object name" We don't recommend it, Because we cannot know which of its classes it is.

Here we need to note that there are three points: Call method is whose method, lifeline, activation period.

The most confusing place I've ever been was Dotwo () is this a method that calls a B object in a object method? In fact, it is not, timing diagram because it is the interaction of the action, only B contains the Dotwo () method, a can interact with B, if there is a method call B in a, then we use the relationship between the class is not able to implement the dependency relationship .

Another point is the activation period, like the two period of activation in B is disconnected, the call two methods are not associated, is called in a, usually we are in the activation period of the upper end of the Write method call, and at the lower end write return information or do not write.

and the existence of the lifeline is the existence of the object, when the object B is not called MYB when B is already there, the result should be what? We may as well write the code (of course, such a class name is really heinous, but simple, haha):

public class B () {public         void Dotwo () {};         public void Dothree () {};              }


We are easy to write Class B, that Class A:

public class A () {public          B MyB;          public void Doone () {                   myb=new B ();                   Myb.dotwo ();                   Myb.dothree ();          };}


Because the time series diagram is from top to bottom, it is easy to see the entire process of this interaction, since there are already two classes above, the only thing to do is to start the process up:

public class begin () {public          static void Main (String[]args) {               a a=new a ();               A.doone ();          }}

So the whole interaction is not very clear. Of course there are some representations, such as asynchronous messages, self-correlating messages, and certain conditional messages, that we can infer based on the same understanding, which is not described in detail here.

Examples of UML time series diagrams

In the process of understanding the sequence diagram, I have seen a very good article in the blog Park, but also let me understand the beginning of the timing diagram, unfortunately, I did not record the site, and now find instead of finding it, but fortunately, at that time, he asked the question cut a map, has been preserved, This is what we're going to tell you about:

It should be the author said to understand the three diagram, time series diagram will understand a similar, I believe that it was preserved, and it turns out that I have read over a period of time, but also really understand some, no wonder the author dare so confident.

The difference between these three graphs is that the activation period of part B is different, so let's write it separately:

The first one:

public class C () {public          void T () {};          public void S () {};} public class B () {          private C cc;          public void M () {                 cc=new C ();                 CC.T ();          };          public void Anothermethod () {//here does not show the name of the class, its own casually named                 Cc=new C ();                 Cc.s ();          }} public class A () {public          static void Main (String[]args) {                  b bb=new b ();                  BB.M ();          }}


The second one:

public class C () {public          void T () {};          public void S () {};} public class B () {          private C cc;          public void M () {          };          public void Unkownmethod () {//                 cc=new C ();                 CC.T ();          }          public void Anothermethod () {//here does not show the name of the class, its own casually named                 Cc=new C ();                 Cc.s ();          }} public class A () {public          static void Main (String[]args) {                  b bb=new b ();                  BB.M ();          }}

The third one:

public class C () {public          void T () {};          public void S () {};} public class B () {          private C cc;          public void M () {              cc=new C ();              CC.T ();              Cc.s ();          };} public class A () {public          static void Main (String[]args) {               b bb=new b ();               BB.M ();          }}

This will be three to write, is not to understand a lot

The practice of UML time series diagram

In fact, when I learned the time series diagram, I once got a picture of God, but also I understand the timing diagram of the most critical picture, here with you to share, see you may wish to practice under the OH:

Ready to leave, once decided to do one thing, it is really difficult to continue to indulge in the past state, for their own refueling bar, fighting ....

Accumulate Kuibu, Poly stream-------about UML time series diagram

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.