This is because I have already introduced three layers in the previous article. 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 basic 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. For example, you can add an appearance mode to the U and B layers. In general, this is what the table is in the package diagram.
In addition, there is a more important part, that is, the above implementation is also very easy, and it is the same as the design pattern without adding: 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: The above can draw a conclusion that the program development sequence is to plot the program first, rather than simply typing the program directly. Let's assume that we have made all the figures out and analyzed each step clearly. I wonder that it will be very good when I try to program. We usually take it directly and try it out. In fact, this is a bad habit, so we have to change it. We can only improve it in this way.