Software Module Communication via Event Bus Mediation
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing communication methods between software modules face issues such as reference errors, memory leaks, increased coupling between modules, undefined event sending ranges, and limited flexibility in communication modes.
Innovation Solution
A communication method where software modules register and unregister accessible or subscribable services based on their life cycles, allowing modules to access or subscribe to services only when they exist, thereby reducing coupling and avoiding reference errors.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Productivity
If software modules communicate by directly calling methods in other modules, then communication efficiency is improved, but coupling degree between modules increases
Solution Approach 1:
The patent introduces an event bus as an intermediary component that mediates communication between software modules. Instead of modules directly calling each other's methods, they publish and subscribe to events through the event bus, which acts as a mediator. This reduces direct coupling between modules while maintaining communication efficiency, as the event bus handles the coordination and routing of messages between modules.
2Device complexity
If software modules use event bus for communication, then coupling degree is reduced, but type of communication data cannot be determined
Solution Approach 1:
The patent enhances event objects by adding a data type parameter that explicitly defines the type of communication data being transmitted. This parameter change allows the system to determine and validate data types dynamically, solving the problem of undetermined data types in event bus communication while maintaining the low coupling benefits.
3Speed
If software modules directly reference other modules, then communication speed is improved, but memory leak problems occur
Solution Approach 1:
The event bus serves as an intermediary that manages module references dynamically. Modules publish events and subscribe to events without maintaining direct references to each other. The event bus handles the subscription management and event routing, ensuring that references are properly created and released, thus preventing memory leaks while maintaining communication speed.
Solution Approach 2:
The patent implements dynamic subscription management where modules can subscribe to and unsubscribe from events based on their current state and needs. This dynamic approach allows the system to optimize communication speed by maintaining active subscriptions while preventing memory leaks by automatically releasing references when modules are destroyed or no longer need the communication channel.
4Reliability
If software modules maintain direct references, then communication reliability is improved, but flexibility in communication modes is limited
Solution Approach 1:
The event bus provides a universal communication framework that supports multiple communication modes (publish-subscribe, request-response, broadcast) through a single interface. This multi-functional design allows modules to communicate reliably while maintaining flexibility to switch between different communication modes based on specific needs, without requiring separate direct reference mechanisms for each mode.
Data Source
AI summary
A communication method, apparatus, device and medium between software modules are provided. The communication method includes: registering, in response to a creation of a first module implemented based on a preset first interface, an accessible service corresponding to the first interface in the first module, and unregistering the accessible service in response to a destruction of the first module; and finding, by a second module, whether the registered accessible service exists, and when the registered accessible service exists, accessing, by the second module, the accessible service.


