mardi 19 mars 2019

C++ Module architecture, Module circular dependency

At work we have a software C++ project based on Qt5. Currently our project has 7 Modules. Each has a separate role.

Our current problem lies in 2 specific modules:

  • Network
  • Device

The Network module does all networking, creating sockets, receiving data and so on. The Device module is well, a description of all devices that can be connected to this program and their methods and ways to manipulate them.

What we cannot figure out is the best course of action for the dependencies of each other because we need to have a dynamic list of all Devices. These Devices are added to this list through a specificly made protocol, that the Network module catches. My colleagues say that the Network module should have all the Devices listed, but i say that the Network module has no business there. So currently we have the Network module depending on Device and the Device module depending on Network. My ideas are as follow:

  1. Create a new module, which wraps up the whole protocol and let the Network module only control the low level networking while having a list of callbacks, that could be added to add said Devices to the list in the Device module.

  2. Make everything in one whole module and forget about the brainstorming and end up with a huge puddle of code, that can't be managed, nor tested well.

I need some concrete advice here for a solution, that is long term and lasting for maintaining and testing the code as easily and stress free as possible.

Aucun commentaire:

Enregistrer un commentaire