• Español (España, alfabetización internacional)
    • English (United States)
    • العربية (مصر)
    • Deutsch (Deutschland)
    • français (France)
    • हिंदी (भारत)
    • italiano (Italia)
    • 日本語 (日本)
    • 한국어 (대한민국)
    • Nederlands (Nederland)
    • polski (Polska)
    • русский (Россия)
    • ไทย (ไทย)
    • Türkçe (Türkiye)
    • Tiếng Việt (Việt Nam)
    • 中文(中华人民共和国)
    • 中文(香港特別行政區)
  • Inicio de sesión
  • Registro
DotNetAge - Mvc & jQuery CMS
Ocultar sidebar

Facade


Definition



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.

UML class diagram





Participants



The classes and/or objects participating in this pattern are:
  • Facade
knows which subsystem classes are responsible for a request.

delegates client requests to appropriate subsystem objects.

  • Subsystem classes
implement subsystem functionality.

handle work assigned by the Facade object.

have no knowledge of the facade and keep no reference to it.


Sample code in C#




public class OrderFacade
{
//Places an Order and Returns an Order ID
public int placeOrder(int CustomerID, List Products)
{
Order anOrder = new Order();
OrderLine anOrderLine = new OrderLine();
Address DespatchAddress = Address.getCustomerDespatchAddress(CustomerID);
int OrderId = anOrder.requestOrderID();

anOrder.createOrder(OrderId, DespatchAddress);
anOrderLine.addOrderLinesToOrder(OrderId, Products);

return OrderId;
}
}

//order class
public class Order
{
public int requestOrderID()
{
//Creates and Returns a Unique Order ID
}

public void createOrder(int OrderId, Address DespatchAddress)
{
}
}

//OrderLine Class
public class OrderLine
{
public void addOrderLinesToOrder(int OrderId, List Products)
{
}
}

//Public Customer
public class Address
{
public static Address getCustomerDespatchAddress(int CustomerID)
{
return new Address();
}
//Address properties
}

public class BasketItem
{
//BasketItem Properties
}

 


    Average:
  • Lee
    (713)
  • Enlace permanente
Compartir:

Tag cloud

Anything in here will be replaced on browsers that support the canvas element