Author - StudySection Post Views - 87 views
Facade Design

Facade Design Pattern In C#

The facade design pattern in C# is used to provide an interface to a framework, library or classes in a simplified way.
In developer language, this pattern hides the complexity of the code and logic and shows only the interface to the user.
This pattern gets implemented using one wrapper class with a set of methods available for the user. This pattern is particularly used when a system is very complex or difficult to understand and has multiple subsystems.

Let’s understand with an example

This is the interface specific to the burger.
public interface IBurger {
void GetVegBurger();
void GetNonVegBurger();

This is a burger provider class which will get burgers for their clients. Here methods can have other private methods which the client is not bothered about.
public class BurgerProvider: IBurger {
public void GetNonVegBurger() {
Console.WriteLine("Getting Non Veg Burger.");
public void GetVegBurger() {
Console.WriteLine("Getting Veg Burger.");
private void GetNonVegToppings() {
Console.WriteLine("Getting Non Veg Burger Toppings.");

Similarly, this is the interface specific for the bread.
public interface IBread {
void GetGarlicBread();
void GetCheesyGarlicBread();

And this is a bread provider class.
public class BreadProvider: IBread {
public void GetGarlicBread() {
Console.WriteLine("Getting Garlic Bread.");
public void GetCheesyGarlicBread() {
Console.WriteLine("Getting Cheesy Garlic Bread.");
private void GetCheese() {
Console.WriteLine("Getting Cheese.");

Below is the restaurant façade class, which will be used by the client to order different burgers or breads.
public class RestaurantFacade {
private IPizza _PizzaProvider;
private IBread _BreadProvider;
public RestaurantFacade() {
_PizzaProvider = new BurgerProvider();
_BreadProvider = new BreadProvider();
public void GetNonVegPizza() {
public void GetVegPizza() {
public void GetGarlicBread() {
public void GetCheesyGarlicBread() {

Finally, below is the main method of our program,
void Main() {
Console.WriteLine("----------------------CLIENT ORDERS FOR BURGERS----------------------------\n");
var facadeForClient = new RestaurantFacade();
Console.WriteLine("\n----------------------CLIENT ORDERS FOR BREAD----------------------------\n");

StudySection has a long list of certification exams that it offers through its online platform. The PHP Certification Exam is one of the programming certifications that it provides. Whether you are new to PHP programming or you have extensive experience in PHP programming, you can get a certification according to your level. Attach a PHP certification with your resume to get the most out of job offers.

Leave a Reply

Your email address will not be published. Required fields are marked * cratosroyalbet betwoon grandpashabet grandpashabet giriş deneme bonusu veren siteler casino siteleri