Passing queues among different modules
In this recipe, we will pass Queues
around different modules. As our GUI code increases in complexity, we want to separate the GUI components from the business logic, separating them out into different modules.
Modularization gives us code reuse and also makes the code more readable.
Once the data to be displayed in our GUI comes from different data sources, we will face latency issues, which is what Queues
solve. By passing instances of Queues
among different Python modules, we are separating the different concerns of the modules' functionalities.
Note
The GUI code ideally would only be concerned with creating and displaying widgets.
The business logic modules' job is to only do the business logic.
We have to combine the two elements, ideally using as few relations among the different modules, reducing code interdependence.
Note
The coding principle of avoiding unnecessary dependencies is usually called "loose coupling".
In order to understand the significance...