Façade Pattern Code Review

Define the Façade Object

Code Download

  • Download Description:façade pattern download
  • .NET Framework:3.5
  • .NET Language:C#
  • Date Published:2009-07-01
  • Download Size:8 KB

Code Review

Code Walkthrough

Define the Facade class which provides a common view into the defined high-level systems (objects).

class Facade { private BankSystem bank = null; private LoanSystem loan = null; private CreditSystem credit = null;
public Facade() { bank = new BankSystem(); loan = new LoanSystem(); credit = new CreditSystem(); }
public Boolean IsEligible(String customerID, Int32 amount) { Boolean eligible = true;
Console.WriteLine(String.Format("Customer {0} applies for {1:C} loan\n", customerID, amount));
if (!bank.HasSufficientSavings(customerID)) { eligible = false; } else if (!loan.HasNoBadLoans(customerID)) { eligible = false; } else if (!credit.HasGoodCredit(customerID)) { eligible = false; } return (eligible); } }

The IsEligible() method will invoke separate methods in each individual object and return a single response.