c# - Observer Pattern or just create event handling? -
i want create "modules" layout in web application can add more modules of same type, example:
as example, webapp handles subscriptions , email campaigns, , want create interface allow coupling multiple api's, mailchimp, campaignmonitor, icontact, etc...
so create imailingservice
interface set ground rules , modules implement
public class campaignmonitorservice : imailingservice
so far good...
how fire interface method upon action on webapp?
should implement observer design pattern, should simple create event handlers, or other hook?
for example, upon user subscription fire addsubscriber
method on interface
addsubscriber(string email, string[] args);
some thing creating list, unsubscribing, etc, etc...
what best approach handle such scenario?
event handlers are how observer pattern implemented in .net. pattern first class citizen of .net world, how iterator pattern built in (with foreach
, yield return
).
if want use pattern without events/event handlers, can use new iobserver<t>
, iobservable<t>
(introduced in .net 4.0).
Comments
Post a Comment