In the previous article, I talked about the benefits and actual application scenarios of the factory method for HTML element output. Here I will honor it:
1) you can attach many responsibilities. This is an advantage of many design models.
Constructor design modes such as factory methods are also a major advantage. Typical application scenarios:
A) Check the legitimacy of Enterprise Development: using the method provided by Microsoft or the 3rd-party method is also a good choice, but for a more flexible design approach, putting verification information in a class or database is actually a better choice. In this way, the factory method is used to output HTML elements. Although HTML elements need to be spliced, the benefits are very high, the validation rules can be implemented in a unified manner, and the Implementation can be delayed;
B) multi-language processing: If the processing is based on the traditional multi-language provided by Microsoft, it is difficult and inflexible in the cloud environment and cannot be processed in some places, such as the multi-language of dictionary data, if the multi-language data warehouse is implemented, and the control output is followed by a certain rule to handle the multi-language responsibility, it is very simple and flexible.
Of course, with this idea of attaching responsibility, many functions can be implemented in this factory method, such as form element display control and form button permission control.
However, using this method also has its own shortcomings. First, when there are too many responsibilities attached, this mechanism will be large and complex. Second, it willProgramMembers have lost a lot of fun and are not so pure at the same time.