As I have already introduced three layers in the previous article, I will not introduce them here. 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 main 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, such as adding an appearance pattern to the U and B layers. In general, this is what it looks like in the package diagram.
In addition, there is a more important part, that is, the above implementation is also very simple, and the same as the design pattern is not added: 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: We can draw a conclusion from the above that the program development sequence is to draw a picture first, instead of simply hitting the program. If we get all the images, we will analyze each step clearly, and we will be very comfortable with the program. We usually just pull it and try it out. In fact, this is a very bad habit, so we have to change it. Only in this way can we continue to improve.