Created
January 8, 2012 20:34
-
-
Save rbwestmoreland/1579576 to your computer and use it in GitHub Desktop.
Properly Implementing the Facade Pattern
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
/// <summary> | |
/// The object which delegates to the appropriate sub-system. | |
/// <para>The Facade pattern is a structural pattern, whose | |
/// purpose is to provide a unified interface to a set of | |
/// interfaces in a subsystem.</para> | |
/// </summary> | |
public class Facade | |
{ | |
#region Property(s) | |
protected ISubSystemA SubSystemA { get; set; } | |
protected ISubSystemB SubSystemB { get; set; } | |
#endregion Property(s) | |
#region Constructor(s) | |
public Facade(ISubSystemA subSystemA, ISubSystemB subSystemB) | |
{ | |
SubSystemA = subSystemA; | |
SubSystemB = SubSystemB; | |
} | |
#endregion Constructor(s) | |
#region Method(s) | |
public virtual void ProcessA() | |
{ | |
SubSystemA.Process(); | |
} | |
public virtual void ProcessB() | |
{ | |
SubSystemB.Process(); | |
} | |
#endregion Method(s) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
/// <summary> | |
/// An interface of a sub-system, which | |
/// we want to unify. | |
/// </summary> | |
public interface ISubSystemA | |
{ | |
void Process(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
/// <summary> | |
/// An interface of a sub-system, which | |
/// we want to unify. | |
/// </summary> | |
public interface ISubSystemB | |
{ | |
void Process(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment