How can I take advantage of IObservable/IObserver to get rid of my "god object"?

Posted by Will on Stack Overflow See other posts from Stack Overflow or by Will
Published on 2010-02-16T18:09:16Z Indexed on 2010/04/26 9:03 UTC
Read the original article Hit count: 208

In a system I'm currently working on, I have many components which are defined as interfaces and base classes. Each part of the system has some specific points where they interact with other parts of the system.

For example, the data readying component readies some data which eventually needs to go to the data processing portion, the communications component needs to query different components for their status for relaying to the outside, etc.

Currently, I glue these parts of the system together using a "god object", or an object with intimate knowledge of different parts of the system. It registers with events over here and shuttles the results to methods over there, creates a callback method here and returns the result of that method over there, and passes many requests through a multi-threaded queue for processing because it "knows" certain actions have to run on STA threads, etc.

While its convenient, it concerns me that this one type knows so much about how everybody else in the system is designed. I'd much prefer a more generic hub that can be given instances which can expose events or methods or callbacks or that can consume these.

I've been seeing more about the IObservable/IObserver features of the reactive framework and that are being rolled into .NET 4.0 (I believe).

Can I leverage this pattern to help replace my "god object"? How should I go about doing this? Are there any resources for using this pattern for this specific purpose?

© Stack Overflow or respective owner

Related posts about .NET

Related posts about iobservable