Click here to Skip to main content
15,885,125 members
Articles / Programming Languages / C#

Aggregator Provider Pattern: An Extension of Provider Pattern

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
28 Jan 2013CPOL2 min read 8.8K   4  
Aggregator Provider Pattern enables us to create and utilize multiple instance of a class having the same provider interface.

Definition

Aggregator Provider Pattern is an extension of Provider Pattern, which enables us to create and utilize multiple instances of the class having the same provider interface. In this pattern, there is an Aggregator class which implements the provider interface and contains a collection of instances of classes having the same provider interface.

The underlying caller class of this aggregator is simply unaware of how many provider instances the caller Provider Aggregator contains, but all of the provider instances will be utilized with a single invocation from the caller class.

image

Comparison with Provider Pattern

Provider Aggregator Pattern is fully compatible with the existing Provider Pattern and the power of provider pattern can be easily extended to use multiple providers concurrently without any modification on the caller classes that were using a provider.

In short, Provider Pattern is concerned with the utilization of one of the available providers; whereas Aggregator Provider Pattern is concerned with the utilization of all of the available providers at the same time.

Example Demonstration

Aggregator Provider Pattern is useful when we need a configurable framework to add/remove multiple services used by one caller/user. For instance, we can have Logger Provider framework, where we need log information to be saved in text files, save to database and sent to email addresses and so on. Having an easy configurable framework along with Aggregator Provider Pattern will enable us to add or remove more services without requiring the code modification in the code that uses this provider.

image

Regarding the example case that has just been described can utilize the Aggregator Provider Pattern, by creating the classes as illustrated above. The code snippet below shows a basic usage of this pattern, where the last line will perform the log operation based on a list of log providers loaded in the aggregator class dynamically.

image

Download the latest white paper and samples from MSDN Code Gallery.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Chief Technology Officer
Bangladesh Bangladesh
Mohammad Ashraful Alam is a Software Engineer, who is dedicated to Microsoft .NET based development. This Bangladeshi national is involved with project management and development of several US based software projects from his country. Already he has managed and developed 15 software projects, which are being used by several users of different countries, such as USA, Canada, Australia, and Bangladesh. While developing and managing a team, he contains and maintains a set of well defined engineering practices developed by him and other online developer community. Beside software development, he has also written several technical articles and research papers published by IEEE Computer Society and many other worlds recognized publishers.

Before becoming engaged with software development, he was involved with Bengali literature and several Bengali news papers as freelance journalist and published around 150 articles, essays and short stories.

Due to his willingness to give effort to improve and share better software development practices, Ashraf has awarded as “Most Valuable Professional” (MVP) in ASP.NET category by Microsoft for multiple times, since 2007.

When not engaged with technical stuffs, he likes to pass time with his friends, and family members, listens music or watches TV.

Check his portfolio at: http://www.ashraful.net/.

Check his blog: http://blog.ashraful.net/.

Catch him thru mail: admin [attt] ashraful [dotttt] net (anti-spam text).

Comments and Discussions

 
-- There are no messages in this forum --