Sunday, September 13, 2009

Facade Pattern with C#

Facade Pattern classified into Structural Pattern is unified interface that represents entire by hiding the complexities.

It provides the higher level interface which makes subsystem easier to use. It provides client with a single entry point which eliminates knowing the complexity of many subsystems beneath it.

In this pattern, facade object is aware of the responsibility owned by subsystem classes. It essentially delegates the client request to subsystem classes; whereas sub-system classes perform operation as assigned by facade object and doesn’t holds any reference to it.

Below is the sample class diagram demonstrates Facade pattern where client makes a call to Facade class and the subsystem operations are managed by facade thereby eliminating the client to directly deal with subsystems.

Code for Facade Class:

namespace MyProject.FacadePattern
public class Facade

private IValidateUser _validateuser;
private IAddUser _adduser;
private INotifyService _notifyservice;

public Facade()
_validateuser = new ValidateUser();
_adduser = new AddUser();
_notifyservice = new NotifyService();

public bool AddUser(User user)
if (!_validateuser.ValidateUser(user))
return false;


< Back to Design Patterns

1 comment:

  1. Hi............

    Thanks for your marvelous posting! I quite enjoyed reading it, you are a great author.I will be sure to bookmark your blog and definitely will come back from now on. I want to encourage that you continue your great job, have a nice day.

    Fa├žade design