A day with .Net

My day to day experince in .net

Facade Pattern

Posted by vivekcek on September 8, 2012

A facade is an object that provides a simplified interface to a larger body of code, such as a class library.
Look at the example below where the ‘SoftwareCompany’ abstract the building step of a software.

Provide a unified interface to a set of interfaces in a subsystem. Facade defines a higher-level interface that makes the subsystem easier to use

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Facade
{
    class Program
    {
        static void Main(string[] args)
        {
            SoftwareCompany comp = new SoftwareCompany();
            comp.BuildSoftware();
            Console.ReadLine();
        }
            
    }
    /// <summary>
    /// Abstract the building of a software
    /// </summary>
    class SoftwareCompany
    {
        private RequirementAnalysis rqAnlysis = null;
        private Design design = null;
        private Coding coding = null;
        private Testing testing = null;
        private Deploying deploy = null;
        public SoftwareCompany()
        {
            rqAnlysis = new RequirementAnalysis();
            design = new Design();
            coding = new Coding();
            testing = new Testing();
            deploy = new Deploying();
        }
        public void BuildSoftware()
        {
            rqAnlysis.DoRequirementAnalysis();
            design.DoDesign();
            coding.DoCoding();
            testing.DoTesting();
            deploy.DoDeploying();
        }
    }
    class RequirementAnalysis
    {
        public void DoRequirementAnalysis()
        {
            Console.WriteLine("RequirementAnalysis");
        }
    }
    class Design
    {
        public void DoDesign()
        {
            Console.WriteLine("Design");
        }
    }
    class Coding
    {
        public void DoCoding()
        {
            Console.WriteLine("Coding");
        }
    }
    class Testing
    {
        public void DoTesting()
        {
            Console.WriteLine("Testing");
        }
    }
    class Deploying
    {
        public void DoDeploying()
        {
            Console.WriteLine("Deploying");
        }
    }
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s