SlideServe
Menu
Préférences
© SlideServe · v2026

Façade Pattern

morse avatar
14 diapositives · 344 Views · Jul 11, 2014

Façade Pattern. Seung Ha. Façade?. 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. High-level Interface.

Façade Pattern - slide 1
01 / 14Façade Pattern
1 / 17

Télécharger la présentation

Façade Pattern
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. Façade Pattern Seung Ha

  2. Façade? • 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. High-level Interface 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. client classes subsystem classes facade

  4. When Façade Pattern is used? • To provide simple interface to a complex subsystems. • To decouple the subsystem from clients and other systems. • To layer subsystems.

  5. Structure and Participants • Façade • The façade class interacts subsystem classes with the rest of the application. • Subsystem classes • Software library / API collection accessed through the façade class • Clients • The objects using the façade pattern to access resources from the subclasses Client1 Client2 facade DoSomething() Class1 Class3 Public void DoSomething() { Class1 book = new Class1(); Class2 customer = new Class2(); Class3 billing = new Class3(); book.CheckStock(); customer.GetShippingInformation(); billing.Process(book, customer); } Class2

  6. Consequences • 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. Implementation • Reducing client-subsystem coupling: • 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: • Public interface to a subsystem consists of classes that all clients can access (Façade class is part of the public interface.) • Private interface is just for subsystem extenders.

  8. Sample Code Client Web Page <Classes> • 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 Business Logic <Classes> Facade Data Object <Classes> Data Access Subclasses Database SQL Server Database Access

  9. Sample Code Client – ASP.NET page ... private void GetData(intproductID) { 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.Productsobj = new VOM.ObjectModel.Northwind.Products(login.ConnectionString); obj.GetData(productID); SetData(obj); } ...

  10. Sample Code Business Object [Serializable()] public class Products { ... public virtual void GetData(intproductID) { try { XLMLDataTablexdt = 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 (XLMLDataRowxdr in xdt.XLMLDataRowList) { Products obj = this; xdr.SetAttribute(obj); }; } catch (System.Exception ex) { throw ex; } } ... }

  11. Sample Code Façade – Data Object public class XLMLDataTable:XLML { ... public void GetData() { try { if (this.ConnectionString != string.Empty || this.CommandText != string.Empty) { XLMLDataTablexlmlDataTable = 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; } } ... }

  12. Sample Code Data Access Subclass public class XLML { ... protected XLMLDataTableGetXLMLDataTable(SqlDataReadersqlDataReader) { XLMLDataTablexlmlDataTable = new XLMLDataTable(); try { SetDataTableSchema(sqlDataReader, ref xlmlDataTable); SetDataRowList(sqlDataReader, ref xlmlDataTable); } catch (Exception ex) { throw ex; } finally { sqlDataReader.Close(); } return xlmlDataTable; } ... }

  13. Demo

  14. References • Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides. Design Patterns. Addison-Wesley Professional Computing Series • Wikipedia – Façade & Façade pattern