Three-tier + Design Mode

Source: Internet
Author: User

As I have already introduced three layers in the previous article, I will not introduce them here. The main content of this article is how to implement the three layers + design mode. The first thing we need to do is add and add?

The main purpose of Layer 3 is to decouple and separate layers so as to change one layer without affecting other layers as much as possible. Therefore, an abstract factory mode can be added to layer B and layer D to achieve this goal. For example:

Of course, you can also add other modes as appropriate, such as adding an appearance pattern to the U and B layers. In general, this is what it looks like in the package diagram.

In addition, there is a more important part, that is, the above implementation is also very simple, and the same as the design pattern is not added: one layer of invocation layer, of course, the simpler method is to figure out the timing sequence. The sequence diagram is as follows:

In the code, you must pay attention to the added design pattern, such as the implementation of the design pattern.

Conclusion: We can draw a conclusion from the above that the program development sequence is to draw a picture first, instead of simply hitting the program. If we get all the images, we will analyze each step clearly, and we will be very comfortable with the program. We usually just pull it and try it out. In fact, this is a very bad habit, so we have to change it. Only in this way can we continue to improve.

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.