Charge system of computer room--Thinking of design mode

Source: Internet
Author: User

Today, with Argento is sailing students briefly discussed the appearance of the model and abstract Factory + reflection + configuration file in the computer room reconstruction application, triggered a few simple thinking, now and June Mutual encouragement:
1. Why does the B-layer think it is reasonable to divide the database tables?        Think twice: B-layer method is to achieve the data table additions and deletions to the logical operation, but also to consider the decoupling effect (I understand the coupling, if only one method in a class, once the error, it only affects itself, the coupling is low; if there are 10 methods, a method error, the instantiation of the class will be wrong, So the coupling degree is stronger, so the class of B layer should not be too many methods, considering that each form is most of the operation of a table, so that each table corresponding to the add and delete operations into a B-level class, most of the calls only need to instantiate a B-layer class can be implemented for the entire form of manipulation tasks, Not only reduce the program execution process, but also reduce the computer burden, why not?
2. Can the exterior layer be implemented with a class? What is the difference between a facade class versus a form? What is the disadvantage of the appearance class according to the data table?
discussion idea: the Appearance class first instantiates the method and then invokes it, each instantiation, as if the class used in the appearance is instantiated once, either in use or unused.        If facade implements all the B-tier methods with a single class, then more than 20 forms each form call is instantiated once the facade class, that is, the B layer all methods are called 20 times, resulting in a large number of useless program execution.
A form of a facade class, the method used to instantiate in the facade class is immediately used, so that all B-tier method instantiation is greatly reduced, basically every execution 1--2 times, so that the burden of the computer will not be very large.
the same analysis method, although the B-layer method will not be called multiple times, but such as the machine checkout and other forms not only use a table, and precisely facade class also according to the table, then the number of calls to the facade class will inevitably increase.
3. Application Advantages of abstract Factory + reflection + configuration file
When it comes to the factory family, it's hard to think of their fondness for switch statements, but if the number of database tables is too large and requires different database switching, Swtich will inevitably add a lot of meaningless judgments, so that through the Factory + reflection + configuration file Way, The implementation of the D-layer method is called directly, and the database can be easily switched.
"Summary"
in the early stage of the design of the computer room is just heard that these design methods and design patterns are directly applied, and the appearance of the application of the pattern is not in place, resulting in a lot of U-layer logic judgments, back to think to realize the beauty of these design patterns, I believe that the next design mode of application learning will be more flexible and convenient.

Charge system of computer room--Thinking of design mode

Related Article

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.