Message subscription and delivery are designed on the "platform-Application of plug-ins in Software Architecture Design
1.First, describe what is "Platform-Plug-in software design.
As the name implies, "platform-plug-in" is to first establish a platform to provide underlying basic services. Based on this platform, in subsequent development, the platform is directly inserted as a plug-in, this design is flexible and scalable.
For example, our computer hardware is an excellent example of "platform-plug-in" design. In a computer, the motherboard is a "Platform", CPU, memory, hard disk, video card, sound card, and nic... These series are all plug-ins. Sometimes the motherboard also solidified the CPU, that is, the CPU function is integrated into the platform.
2.Next, Let's explain what the message subscription and delivery modes are.
This model is easy to understand. For example, the newspaper has set up a copy of the Xiamen Evening News (subscription) for the Xiamen Evening News Agency. Every evening, the newspaper has arranged for employees to deliver newspapers to their homes ). Messages are like newspapers here.
This design mode is different from the general notify y (notification) mode. It is a restricted version of the notify y mode. The notify y mode does not need to be subscribed, but only needs to be delivered, only the message of this event is sent to the receiver at an event point. However, the recipient does not need to subscribe in advance, or the subscription action is not necessarily executed by the recipient in advance. The message subscription and delivery design model requires that the Message Receiver must subscribe to the message before sending the message, just as the newspaper will not send the newspaper to your home for no reason.
3.Implementation Principle
In the design concept of "platform-plug-in", the message subscription and delivery design mode is very useful. Its main function is to greatly reduce the coupling degree, and the low Coupling Degree itself brings a lot of benefits, such as efficiency, maintainability, and scalability. Therefore, for me, low coupling, interface standards, unification, and plug-and-play are the goals I have always pursued in software design.
With the above instructions, we should have a more sensory and clear understanding of the "platform-plug-in" and the concepts of message subscription and delivery. How can we design this system in the next step?
Here we need to introduce several concepts: interfaces, events, and messages.
The interface is the direct interaction port between the platform and the plug-in. The interface provided by the plug-in for sending messages to the plug-in by the platform and the interface provided by the platform for sending and subscribing to the platform by the plug-in. This interface is further embodied in program design. It can be understood as the syntax element supported by most OOP languages: interface ).
Events: events occur on the platform, such as system startup, initialization, user events, and system shutdown.
Message: A description string representing a specific event.
When these events occur, the platform queries the INS in the corresponding event subscription list and sends the messages corresponding to the event to the ins through the interfaces provided by the ins. When the plug-in receives these messages, it can perform corresponding actions.
4.Conclusion
Through the above instructions, we basically have a clear understanding of the "platform-plug-in" design philosophy combined with the message subscription and delivery design patterns. In a system design work, this is proved to be very important and effective two design methods. Of course, in addition to good design ideas and theories, a good system also requires practical actions, the work of an architect or designer requires many development and test engineers to practice and verify the architecture. The architecture that has been continuously tested and honed is a good architecture. Therefore, in addition to excellent R & D technology and rich design experience, an excellent architect or designer must have a modest and willing to listen to his/her opinions, good team spirit and team collaboration skills are required.