Facade Design Pattern in C#.Net

Facade Design Pattern comes under Structural Design Pattern. In short Facade means the exterior appearance. It means in Facade design pattern we hide something and show only what actually client requires.

If you are new to Design Pattern, please read my earlier blog - Design Pattern in ASP.Net

What is Facade Design Pattern?
Facade design Pattern is use to make a complex system easier.

So basically when and how to implement Facade Design Pattern?
Facade Design Pattern should be implemented -
When system is more complex with large number of classes.

In Facade Design Pattern client does not need to know all classes or subsystems to work. Client only require a Facade class which will automatically call connected subsystems and classes internally.

For eg- If you buy a product from any e-commerce website, you just login to system, select your product and place the order. You event don't know whats going on behind the screen.

There could be various logic running behind the screen.

1. Checking inventory
2. Checking nearest warehouse location.
3. Checking any offer/discount for customer.
4. Payment system

and many more.


Below picture explains about Facade Design Pattern.
Facade Design Pattern in C#
You can see in above example that Client 1,2,3,....n will only connect Order Management class which implements Facade Design Pattern. And then Order Management class will call subsystem1 and susbsytem2 based on business logic implemented in system.

Comments

Popular posts from this blog

CAML Query in SharePoint 2010

Calling REST APi from server side code - C#

All about SharePoint 2010 Content Type Hub

SharePoint Interview Questions and Answers

Calling ASP.Net WebMethod using jQuery AJAX