Click here to Skip to main content
15,886,724 members
Articles / Programming Languages / C#

Unplugging Design Patterns - Facade

Rate me:
Please Sign up or sign in to vote.
4.00/5 (1 vote)
18 Jul 2012CPOL2 min read 17.9K   3  
Facade is the most simple (arguably after Singleton) design pattern and makes programming beautiful and useful.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FacadeLib
{
    public class Mortgage_Facade
    {
        private Bank_Subsystem bank;
        private Loan_Subsystem loan;
        private Credit_Subsystem credit;

        public bool IsEligible(Customer cust)
        {
            bool isEligible = true;

            bank = new Bank_Subsystem();
            if (!bank.IsValidCustomer(cust))
            {
                isEligible = false;
            }

            loan = new Loan_Subsystem();
            if (isEligible && !loan.HasNoBadLoan(cust))
            {
                isEligible = false;
            }

            credit = new Credit_Subsystem();
            if (isEligible && !credit.HasGoodCredit(cust))
            {
                isEligible = false;
            }

            return isEligible;
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
India India
I have more than 5 yrs of work ex as a software developer for a Financial Consulting firm and an Investment bank. My technical expertise include C# programming,WPF,WCF, SSRS reporting,ASP.Net and MS SQL (2005 & 2008).

Comments and Discussions