Facade pattern is a very simple but useful pattern.When I think of Facade pattern.. what comes to my mind is composition.
Complex System ----> Sub System 1
----> Sub System 2
----> Sub System 3
----> Sub System 4
For an external system we can create a wrapper which hides all the subsystems and provides an unified interface. Internall this wrapper will dispatch the call to the correct subsystems.
For eg:
public Class ComplexSystem
{
private SubSystem _subSystem1;
private SubSystem _subSystem2;
private SubSystem _subSystem3;
public void SubSystem1Method1()
{
_subSystem.Method1();
}
public void SubSystem2Method1()
{
_subSystem2.Method1();
}
public void SubSystem3Method1()
{
_subSystem3.Method1();
}
public void SubSystem4Method1()
{
_subSystem4.Method1();
}
}
I hope this explanation helps. You can donwload a real world example here: http://dotnetdevblog.googlepages.com/FacadePatters.zip
Thanks,
Yash
Sunday, August 16, 2009
Subscribe to:
Posts (Atom)
