vendredi 5 mars 2021

Is chaining signals together to pass data between loosely coupled good practice? [closed]

I have started on a project in which I try to keep the frontend separated from the backend. This has carried me down a path to a place where it takes three signals and three callbacks from when a user clicks on a button to the effect becomes visible in the widget.

The initial signal travels "down" into the backend via an intermediate layer, and then back up to the front end again via the intermediate layer. It looks kind of like this

enter image description here

And the class structure looks approximately like this

enter image description here

The question is if this is an overly complex way of doing it. Or perhaps it is not complex enough, in the sense that too much stuff is taking place in the Main class. I am not used to handling very large projects, but I would like for this to scale somewhat nicely.

I could definitely "un-link" some of the signal chains if I accepted a stronger degree of coupling between the classes. Currently all signal connections are happening in the Main class (apart from trivialities such as coupling a toolbar action's triggered signal with its own onTriggered callback). All cross-class connections take place in Main, and I can easily envision that there will be a loooot of connections as the list of features grows.

So what is a good way of keeping the code clean and readable?

Aucun commentaire:

Enregistrer un commentaire