Question

I have many classes in my application responsible for behaviour- views, controllers, models, network- often the state of one class or system depends on another and I'm finding that classes that are primarily responsible for the behaviour for one system inevitably become dependees or dependers of other systems or classes. I've tried passing in interfaces of dependencies from the constructor of the system all the way to the class the depends on it and registering for events on it but this gets extremely complex and crazy and definitely violates OCP and SRP at least.

I'm considering making an event system that all event dispatching and listening classes would be coupled to, providing a layer of indirection for classes that require interaction with classes from other systems however in the worst case behavioural classes could be responsible for the behaviour of a class, handling events, and dispatching events- so that definitely also violates the SRP even though I'm pretty sure it would follow the OCP.

Is there a better solution out there? Am I applying these principles correctly? I'm very hesitant to use an event system as it will require most classes to be extremely tightly coupled with it.

No correct solution

Licensed under: CC-BY-SA with attribution
scroll top