Subscribe/Publish Model in Web-based Application (c#) - Best Practices for Event Handlers

Posted by KingOfHypocrites on Programmers See other posts from Programmers or by KingOfHypocrites
Published on 2012-03-02T17:20:45Z Indexed on 2012/03/31 11:41 UTC
Read the original article Hit count: 207

I was recently exposed to a desktop application that uses an publish/subscribe model to handle commands, events, etc. I can't seem to find any good examples of using this in a web application, so I wonder if I am off base in trying to use this for web based development (on the server side)? I'm using asp.net c#.

My main question in regards to the design is: When using a publish/subscribe model, is it better to have generic commands/events that pass no parameters and then have the subscribers look at static context objects that contain the data relevant to the event? Or is it better to create custom arguments for every event that contain data related to the event?

The whole concept of a global container seems so convenient but at the same time seems to break encapsulation.

Any thoughts or best practices from anyone who has implemented this type of model in a web based application? Even suggestions on this model out of the scope of my question are appreciated.

© Programmers or respective owner

Related posts about design-patterns

Related posts about object-oriented-design