lundi 18 septembre 2023

Designing a scalable front-end for network interfaces

I want to provide different mobile network functionalities with an agnostic approach in C++, that is hiding which adapters are used to achieve them (WPA socket, Netlink communication to WiFi chip...). Each functionality is implemented using one of available adapter, but the client code is not aware of which one has been used. Provided network functionalities could grow in time and so also new adapters could be required to implement them (so maybe Network Manager via DBus, ioctl...).

My idea is to:

  • Use Bridge pattern to provide an high level abstraction to client code and decouple from low level implementation. Bridge is mainly used to send commands from client to low level implementation side and it is providing basic functionalities.
  • Use Command pattern to encapsulate request to perform actions on network interfaces. So client code is not calling functions, but creating commands and sending via the Bridge abstraction.
  • Chain of responsibility pattern (CoR) to pass command to proper adapter that can handle the execution.

Assuming that it is a good design, I am not sure how to manage the following things:

  • How I can check (in CoR) if an adapter can handle a command without using switch or downcast?
  • What if command execution provide a result or generate and event? Should I add a getter function for those specific command and then client code should call it or it would be better using a Visitor pattern to trigger a callback to manage the result/event?

Aucun commentaire:

Enregistrer un commentaire