"Room cooperation" re-recognize the appearance mode

Source: Internet
Author: User

Computer room Charge system cooperation version, is our third time with the computer room charge system meet. At the time of personal refactoring, we embarked on a "seven-tier architecture" tour where the façade pattern was developed as a single layer. At that time, also do not understand the appearance is how to play a role, the explanation on the surface easy to understand, after reading oneself also feel very reasonable. However, in the system program, as long as through the BLL logic layer of a method, you need to go through the appearance, thus "decoupling", to avoid the UI layer and the BLL layer directly between the data transfer. At that time, when you hit the code, there is a feeling: every time you write the B-layer logic, but also in the F-layer re-write, this is decoupling and it? Is this the way it looks? Later students also exchanged, found that some people simply skip the appearance, the BLL layer and the UI layer established a connection. I still insist on the appearance from the beginning to the end, the following is the personal reconstruction of the time to recharge the BLL layer code:code for the facade layer:as you can see, my facade façade layer is actually corresponding to the method one by one of my BLL logic layer. Is this the application of the appearance pattern? The answer is:No. The following two sheets are the second edition of the facade layer and the BLL layer of the Machine room cooperation,The façade layer becomes very simple and only needs to instantiate a BLL layer, calling the method:and all a series of logical judgments are in the RECHARGEBLL layer, which also instantiates two other classes of the BLL layer:in personal refactoring, most of the judgment hints are written in the UI layer, which is not common sense. The second version of the code is to make all the logical judgments in the BLL layer. For example, top-up this business, it contains a number of judgments: first, determine whether the number of prepaid card is present, give hints, second, determine whether the prepaid card number is used, give hints; Thirdly, check the balance of the card number; and the first three business judgments belong to other classes in the BLL layer, and now accumulate in a RECHARGEBLL class, so that the appearance layer really play a role? The answer is:No. look at the computer room cooperation last version of the code, first review how to explain the big talk about the appearance of the model. appearance mode (facade), providing a consistent interface to a set of interfaces in a subsystem that defines a high-level interface that makes this subsystem easier to use.  This definition of the individual feel very abstract, after reading, feel reasonable, but it seems to never understand the profound connotation. So, I still take the business logic of recharge, to re-understand the appearance mode.  Here is the appearance of the top-up business with the appearance of the  layer class diagram : Wherein the following three BLL layer is equivalent to the various subsystems mentioned in the book, because this business involves multiple classes in the BLL layer, the appearance can play a role. The surface layer appears to have only one method, in fact, it is the method group, "appearance class, it needs to understand all the subsystems of the methods or properties, to be combined for the outside world to use." "  The following is the improved recharge facade layerCode: The BLL layer code   : This way, is really to achieve the role of the appearance mode." In this way, it is true to realize the charm of the appearance pattern. In this way, the problem of solving the coupling of the system is considered.  Room cooperation This way, Ke bumpy, originally intended to quick, but that is to think. In fact, this is a very long journey. It is both a responsibility and a test that each leader must be pro-Pro. From now on, this is actually a learning opportunity, although experienced, but once again met, there will be a different wonderful. Also is because oneself again and again put down, again and again pick up, just let me, re-understand the appearance mode, really understand the appearance mode. 

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

"Room cooperation" to re-recognize the appearance mode

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.