Question

IObservable<T> and IObserver<T> interfaces are placed directly in the System namespace in .NET Framework 4.0 Beta2. Why not in System.Collections.Generic, like IEnumerable<T>?

p.s. Reactive Framework preview from Silverlight Toolkit contains IObserver<T> in the System.Collections.Generic namespace.

Was it helpful?

Solution

The thing that new IObservable/IObserver interfaces describe is an abstraction much higher than just collections which can be seen as a special case of computations (that's why lists in Haskell are monads). So it's obvious that such generalization is placed to System namespace.

Take a look at this brilliant cast from Erik Meijer where he describes the ideas behind the interfaces.

OTHER TIPS

IObservable is an interface that identifies a class that implements the Observer pattern. Its not related to Collections. Its more related to providing an alternative to Events.

Although this is an old question I stumbled upon, I just wanted to back @ControlFlow's assessment of the 'dualism' between IObservable and IEnumerable as a 'Pushed based' vs 'Pull based' collection with a link to Erik Meijer's 'Rx in 15 Minutes', where he can be quoted as saying exactly that. http://channel9.msdn.com/posts/Charles/Erik-Meijer-Rx-in-15-Minutes/

Consequently, this pushed-based collection can fundamentally shift the basic paradigm of 'a mundane series of called events' into an asynchronous, selectable, query-able, passable and subscribe-able first-class collection of declarative actionable. Something that does that belongs in the core BCL namespace or perhaps deserves it's own, but is too far beyond Yet-Another-Collection to share its namespace. Mind you, that's just my opinion.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top