10-16-2023 04:52 AM
We are developing a framework using LabVIEW. We have separated the framework into the front end and back end and any communication protocols like gRPC, Rest APIs or TCP can be used. To achieve multiple protocol communication functionality, for each utility, we had to go with class architecture to override methods based on the communication protocol used. For example, let’s take a calculator I have front-end UI, client, server, and backend. To support multiple protocols, the design comes as below.
Pros:
Cons:
We would like to know if this is the right approach to switch between protocols or is there any other better approach to easily switch protocols
Please add your thoughts. Thanks in advance
10-16-2023 06:58 PM
You might consider using composition instead of inheritance to define which protocol is used. So when you create your "calculator" you pass in a "protocol" object that it uses to communicate with others. Please excuse the bad uml:
The objective I would be going for with this is to not have to define every method in every protocol, do what you can to keep them generic to reduce the burden of changing them out.
10-18-2023 05:09 AM
Thanks avogadro5
This pattern helped to solve the issue 😊