Download presentation
Presentation is loading. Please wait.
Published byJoan Watson Modified over 9 years ago
1
Seung Ha
2
Façade is generally one side of the exterior of a building, especially the front. Meaning “frontage” or “face” In software architecture, façade defines high level interface to use subsystems.
3
facade client classes subsystem classes Provide a unified interface to a set of interfaces in a subsystem. Façade defines a higher-level interface that makes the subsystem easier to use.
4
To provide simple interface to a complex subsystems. To decouple the subsystem from clients and other systems. To layer subsystems.
5
Façade o The façade class interacts subsystem classes with the rest of the application. Subsystem classes o Software library / API collection accessed through the façade class Clients o The objects using the façade pattern to access resources from the subclasses Client1 Class1 Class2 Class3 Client2 facade DoSomething() Public void DoSomething() { Class1 book = new Class1(); Class2 customer = new Class2(); Class3 billing = new Class3(); book.CheckStock(); customer.GetShippingInformation(); billing.Process(book, customer); }
6
Shields clients from subsystem components. Reducing the number of objects that clients deal with and making the subsystem easier to use. Layer a system and the dependencies between objects. Eliminate complex or circular dependencies. This can be an important consequence when the client and the subsystem are implemented independently. Reducing compilation dependencies – vital in large software systems
7
Reducing client-subsystem coupling : o The coupling between clients and the subsystem can be reduced even further by making Façade an abstract class with concrete subclasses for different implementation of a subsystem. Public vs. private subsystem classes : o Public interface to a subsystem consists of classes that all clients can access (Façade class is part of the public interface.) o Private interface is just for subsystem extenders.
8
Data Access Layer vs. Business Layer Data access subclasses defines how to access databases and meta data. Business logic classes knows how to use data. Façade – Data object Common authentication interface XML standardized data structure Simple interface to access data Database SQL Server Data Access Subclasses Facade Data Object Business Logic Database Access Client Web Page
9
... private void GetData(int productID) { VirtualObjectModel.Framework.Login login = new VirtualObjectModel.Framework.Login( System.Configuration.ConfigurationSettings.AppSettings["LoginID"], System.Configuration.ConfigurationSettings.AppSettings["Password"], System.Configuration.ConfigurationSettings.AppSettings["Database"], System.Configuration.ConfigurationSettings.AppSettings["DatabaseServer"]); VOM.ObjectModel.Northwind.Products obj = new VOM.ObjectModel.Northwind.Products(login.ConnectionString); obj.GetData(productID); SetData(obj); }... Client – ASP.NET page
10
[Serializable()] public class Products {... public virtual void GetData(int productID) { try { XLMLDataTable xdt = new XLMLDataTable(_connectionString); xdt.DataSourceType = XLMLType.DataSourceType.SQLServer; xdt.CommandText = @"SELECT * FROM Northwind.dbo.[Products] WHERE ProductID = @ProductID"; xdt.XLMLParameterList.Add("@ProductID", VirtualObjectModel.Framework.XLMLType.DataType.INT).Value = productID; xdt.GetData(); foreach (XLMLDataRow xdr in xdt.XLMLDataRowList) { Products obj = this; xdr.SetAttribute(obj); }; } catch (System.Exception ex) { throw ex; }... } Business Object
11
public class XLMLDataTable:XLML {... public void GetData() { try { if (this.ConnectionString != string.Empty || this.CommandText != string.Empty) { XLMLDataTable xlmlDataTable = new XLMLDataTable(); switch (this.DataSourceType) { case XLMLType.DataSourceType.SQLServer: xlmlDataTable = GetXLMLDataTable(MSSQLServerDataService.ExecuteReader(this.ConnectionString, this.CommandType,... break; case XLMLType.DataSourceType.Access: xlmlDataTable = GetXLMLDataTable(GetDataTable(this.ConnectionString, this.CommandText)); break; default: break; } this.Description = xlmlDataTable.Description; this.ID = xlmlDataTable.ID; this.XLMLDataColumnList = xlmlDataTable.XLMLDataColumnList; this.XLMLDataRowList = xlmlDataTable.XLMLDataRowList; } catch (Exception ex) { this.Exception = ex; }... } Façade – Data Object
12
public class XLML {... protected XLMLDataTable GetXLMLDataTable(SqlDataReader sqlDataReader) { XLMLDataTable xlmlDataTable = new XLMLDataTable(); try { SetDataTableSchema(sqlDataReader, ref xlmlDataTable); SetDataRowList(sqlDataReader, ref xlmlDataTable); } catch (Exception ex) { throw ex; } finally { sqlDataReader.Close(); } return xlmlDataTable; }... } Data Access Subclass
14
Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides. Design Patterns. Addison-Wesley Professional Computing Series Wikipedia – Façade & Façade pattern
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.