0

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.

1 Answer 1

2

Adding additional layers, each with a certain responsibility is normally a good idea.

Whenever you can identify a clear, separable task that provides a clean interface, then create a new layer/class/module/component for it.

In your case, isolating a device manager seems a very good idea.

Think about creating even more modules. One module low level networking (no device stuff at all). One module device management (no networking). Maybe a third module that contains the the device related network code (as a middle layer between device management and networking)? It is hard to say without knowing more details about your project.

Modules tend to be too big and too complex. I have rarely seen modules that where too small.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.