Application wide messaging... without singletons?
Posted
by StormianRootSolver
on Stack Overflow
See other posts from Stack Overflow
or by StormianRootSolver
Published on 2010-06-05T09:35:22Z
Indexed on
2010/06/05
9:42 UTC
Read the original article
Hit count: 179
So, I want to go for a more Singleton - less design in the future. However, there seem to be a lot of tasks in an application that can't be done in meaningful way without singletons.
I call them "application wide services", but they also fall into the same category as the cross cutting concerns, which I usually fix via AOP.
Lets take an example:
I want an application wide message queue that dispatches messages to components, every component can subscribe and publish there, it's a very nice multicast thing.
The message queue and dispatching system are usually a (rather short) singleton class, which is very easy to implement in, say, C#. You can even use double dispatching and utilize message type metadata and the like, it's all so easy to do, it's almost trivial.
However, having singletons is not really "object oriented design" (it introduces global variables) and it makes testing harder.
Do you have any ideas? I'm asking this question because I'm willing to learn more about this topic, a LOT more. :-)
© Stack Overflow or respective owner