fa ade pattern n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Façade Pattern PowerPoint Presentation
Download Presentation
Façade Pattern

Loading in 2 Seconds...

play fullscreen
1 / 14

Façade Pattern - PowerPoint PPT Presentation


  • 169 Views
  • Uploaded on

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.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Façade Pattern' - morse


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
fa ade
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
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

when fa ade pattern is used
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.
structure and participants
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

consequences
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
implementation
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.
sample code
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

sample code1
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);

}

...

sample code2
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;

}

}

...

}

sample code3
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;

}

}

...

}

sample code4
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;

}

...

}

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