Skip to content

Instantly share code, notes, and snippets.

@alincc
Last active February 2, 2016 17:07
Show Gist options
  • Save alincc/6edd7528fdd73d92a792 to your computer and use it in GitHub Desktop.
Save alincc/6edd7528fdd73d92a792 to your computer and use it in GitHub Desktop.
// Facade
// Intent: wrap a complex subsystem with a simpler interface
class Payment
{
public void deduct(int orderId)
{
System.out.println("Payment check");
}
}
class Inventory
{
public void check(int orderId)
{
System.out.println("Inventory check");
}
}
// Facade class
class OrderFacade
{
private Payment payment = new Payment();
private Inventory inventory = new Inventory();
public void place(int orderId)
{
inventory.check(orderId);
payment.deduct(orderId);
}
}
public class Main
{
public static void main(String[] args)
{
OrderFacade order = new OrderFacade();
order.place(123123);
System.out.println("Order completed");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment