Presentation is loading. Please wait.

Presentation is loading. Please wait.

November 200491.3913 Ron McFadyen1 Façade simplifies access to a related set of objects by providing one object that all objects outside the set use to.

Similar presentations


Presentation on theme: "November 200491.3913 Ron McFadyen1 Façade simplifies access to a related set of objects by providing one object that all objects outside the set use to."— Presentation transcript:

1 November 200491.3913 Ron McFadyen1 Façade simplifies access to a related set of objects by providing one object that all objects outside the set use to communicate with the set defines a higher-level interface that makes a subsystem easier to use

2 November 200491.3913 Ron McFadyen2 Façade Facade knows the subsystem classes and delegates requests to appropriate subsystem objects. Subsystem has no knowledge of the facade - has no reference of it

3 November 200491.3913 Ron McFadyen3 Façade example - Subsystem Bank class class Bank { public bool SufficientSavings( Customer c ) { // check for sufficient savings return true; } }

4 November 200491.3913 Ron McFadyen4 Façade example - Subsystem Credit class class Credit { public bool GoodCredit( int amount, Customer c ) { // check for good credit rating return true; } }

5 November 200491.3913 Ron McFadyen5 Façade example - Subsystem Loan class class Loan { public bool GoodLoan( Customer c ) { // check good loan status return true; } }

6 November 200491.3913 Ron McFadyen6 Façade example - Façade interacts with subsystem class MortgageApplication { int amount; private Bank bank = new Bank(); private Loan loan = new Loan(); private Credit credit = new Credit(); public MortgageApplication( int amount ) { this.amount = amount; } public bool IsEligible( Customer c ) { if( !bank.SufficientSavings( c ) ) return false; if( !loan.GoodLoan( c ) ) return false; if( !credit.GoodCredit( amount, c )) return false; return true; } }

7 November 200491.3913 Ron McFadyen7 Façade example - Customer class class Customer { private string name; public Customer( string name ) { this.name = name; } }

8 November 200491.3913 Ron McFadyen8 Façade example - Façade client public class FacadeApp { public static void Main(string[] args) { MortgageApplication mortgage = new MortgageApplication( 125000 ); mortgage.IsEligible( new Customer( "Gabrielle McKinsey" ) ); } }

9 November 200491.3913 Ron McFadyen9 Façade example - sequence diagram mortgage: MortgageApplication GabrielleMcKinsey: Customer :FacadeApp IsEligible() bank:Bank loan :Loan credit:Credit SufficientSavings() GoodLoan() GoodCredit() new() Mortgage is a façade object that acts as an intermediary between the application and the subsystem

10 November 200491.3913 Ron McFadyen10 Façade A Façade simplifies access to a related set of objects by providing one object that all objects outside the set use to communicate with the set. This avoids the problem of having to reference many different, complicated interfaces to each object of that set.

11 November 200491.3913 Ron McFadyen11 Façade vs Adapter provides an object that acts as an intermediary for method calls between client objects and one other object not known to the client objects. Adapter provides an object that acts as an intermediary for method calls between client objects and multiple objects not know to the client objects. Façade


Download ppt "November 200491.3913 Ron McFadyen1 Façade simplifies access to a related set of objects by providing one object that all objects outside the set use to."

Similar presentations


Ads by Google