I'm working on a large ASP.NET project with a CMS driving lots of data. We have lots of modular components on our pages defined as ASCX controls. Several of these controls need to know about each other to know what data to get from the CMS (i.e. if there's a list of articles in one control, another similar control on the same page cannot have duplicate articles listed). This will result in spaghetti code and too much reliance on each other. We want to implement the mediator pattern to de-couple these connections. I've seen a few C# examples of the mediator pattern but none that translate much to what I need for my site -- or at least its hard for me to translate them in my context. I'm having a hard time getting started so I was wondering if someone could point my in the direction of a more applicable example or provide sample code that translates nicely to my architecture. I've simplified what we're doing below and have some pseudo-code to get the ideas across.
Everything deals with a List<Article>
where an Article
is a class that accesses CMS data for each individual article in the CMS.
GetArticles()
is in a globally available static helper class used by all controls.
TopPromoArticles.ascx (high priority for data)
DataSource = GetArticles().Where( some specific criteria for this control )
LeftPromoArticles.ascx (middle priority for data)
DataSource = GetArticles().Where( some specific criteria for this control && articles not listed in TopPromoArticles.ascx)
FooterArticles.ascx (low priority for data)
DataSource = GetArticles().Where( some specific criteria for this control && articles not listed in TopPromoArticles.ascx && not in LeftPromoArticles.ascx)
Thanks in advance for any help, Mark