I have something like this
Class App Module A Module B Module C Module D
Each of the modules have a single responsibility and are pretty well encapsulated (public interface, private implementation).
The problem is, these modules need to reference each other a lot. (No reasonable way around this, I think.) This has led to a lot of cumbersome parameter passing.
Module A method(B& b) method(int i, C& c) method(bool b, D& d, B& b, C& c)
What if I just put something like
App& app inside
A? (And then initialize
app appropriately.) This way I can just do this:
Module A public: method() method(int i) method(bool b) private: App& app
Looks more readable, seems logical enough. Yes, it is less predictable which modules modify which, but it seems justified. Or am I just being lazy? What is the correct way to approach this kind of problem?