Presentation is loading. Please wait.

Presentation is loading. Please wait.

March 2007ACS - 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: "March 2007ACS - 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 March 2007ACS - 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 March 2007ACS - 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 March 2007ACS - 3913 Ron McFadyen3 Façade example - Subsystem Bank class class Bank { public bool SufficientSavings( Customer c ) {... } }

4 March 2007ACS - 3913 Ron McFadyen4 Façade example - Subsystem Credit class class Credit { public bool GoodCredit( int amount, Customer c ) { … } }

5 March 2007ACS - 3913 Ron McFadyen5 Façade example - Subsystem Loan class class Loan { public bool GoodLoan( Customer c ) { … } }

6 March 2007ACS - 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 March 2007ACS - 3913 Ron McFadyen7 Façade example - Customer class class Customer { private string name; public Customer( string name ) { this.name = name; } }

8 March 2007ACS - 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( "McKinsey" ) ); } }

9 March 2007ACS - 3913 Ron McFadyen9 Façade example - sequence diagram mortgage: MortgageApplication McKinsey: 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 March 2007ACS - 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 March 2007ACS - 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 "March 2007ACS - 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