Machine Room reconstruction package diagram (from three layers + solids to three layers + physical + appearance + Factory + interface +sqlhelper)

Source: Internet
Author: User

When I first started contacting layer three, I only made two examples of login widgets. Drawing a simple package diagram, it can be said that the reconstruction of the back room left a lot of work (because the three-layer understanding of no depth, also did not understand their own things). However, the total owed is still. When the machine room is reconstructed, the problem arises. If only use three layer + entity, I can make, but, require refactoring can not only use three layer + entity, then, must analyze well.

First of all, the layer three + entity: is the presentation layer (U layer) directly invoke the logic of the business logic layer (b layer), the business logic layer in the direct access to the data layer (d layer), after the data returned to layer B back to the U layer. First, the flexibility is not high enough to use only three layers + entities to do the program. If you want to change the database, you need to change a lot of B-layer code. Second, code utilization is not high, like some code to access the database, repeated repeatedly.

Since it is not good, it is necessary to find a new way. b Layer direct access to the D layer is not good, how to do? With the interface. Thus, if the database is changed, as long as the D layer is modified or connected to the new D layer, without changing the B-layer code, the realization of "high cohesion, low coupling." U layer directly access B layer,u layer need to know B layer is too much, coupling is too high. Our system is simple, a on-machine form inside the two main functions, but a form above the content, the U-layer and B-layer correspondence is not very messy? The appearance was then dispatched. This problem can be avoided if you access layer B through the appearance of the U-layer.

So why use SqlHelper? In fact, SQLHelper is a tool, mainly to standardize code and reduce code writing, if you want to learn more, you can see another blog:SQLHelper

Here are the package drawings I drew from three layers + solids to three layers + body + appearance + interface + Factory +sqlhelper.


Summary: First of all, no matter what knowledge at the time, even if very simple, but also to summarize a few words, or the next time, do not know, three layer is a live example. Second, more advice, more exchanges, for not things, diligent hands, wait is not solve the problem. Again, for the three layer of this piece, as long as the pass, the feeling is much better, just started to do package diagram when, really is to start, even if give you ready-made diagram, also will have to see not understand and why will be this appearance of doubt (I believe not only I have this feeling). I suggest that if this happens, first put a diagram, try to understand the process through the code, although it may be a bit difficult, but it is better than to stop or catch a little bit better.

                                                   ,         &N Bsp                          ,         &NB Sp       PS: Welcome to correct me, I appreciate it!

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.