• Skip to primary navigation
  • Skip to content
  • Skip to primary sidebar
  • Skip to footer
  • Core Java
  • Design Patterns
  • JSP
  • Servlets
  • Building Tools
  • jQuery
  • Spring
  • Hibernate
  • Mongo DB
  • More
    • HTML
    • SCJP
    • AJAX
    • UML
    • Struts
    • J2EE
    • Testing
    • Angular JS

J2EE Reference

  • Home
  • About Us
    • Java Learning Centers
  • Contact Us

Façade pattern

March 18, 2011 By j2eereference 2 Comments

The Facade defines a unified, higher level interface to a subsystem, that makes it easier to use.

Lets consider the example for Facade using Phone Order Example

Consumers encounter a Facade when ordering from a catalog. The consumer calls one number and speaks with a customer service representative. The customer service representative acts as a Facade, providing an interface to the order fulfillment department, the billing department, and the shipping department.

Intent

Provide a unified interface to a set of interfaces in a subsystem. Facade defines a higher-level interface that makes the subsystem easier to use.

Problem:

A segment of the client community needs a simplified interface to the overall functionality of a complex subsystem

Illustration: Problem

Consider for example a programming environment that gives application access to its compiler subsystem. This subsystem contains classes such as Scanner, Parser,ProgramNode, ByteCodeStream, and ProgramNodeBuilder that implements te Compiler. Some Specialized applications might need to access these classes directly.

But most clients of  a compiler generally don’t care about details like parsing and byte code generation; they merely want to complier subsysem only complicate their task.

Compiler class can act as a façade, which will provide higher-level interface that can shield clients form these classes, the compiler subsystem also includes a Compiler class. This class defines a unified interface to the compiler’s functionality.

It offers client a single, simple interface to the compiler subsystem. It glues together the classes that implement compiler functionality without hiding them completely.

Applicability

Use the Façade pattern when

You want to provide a simple interface to a complex subsystem.

To tackle the complexity of subsystem as they evolve

Most patterns, when applied, result in more and smaller classes. This makes the subsystem more reusable and easier to customize, but it also becomes harder to use for clients that don’t need to customize it.

A façade can provide a simple default view of the subsystem that is good enough for most client. Only clients needing more customizability will need to look beyond the façade

Façade to decouple the subsystem for clients and other subsystems, thereby promoting subsystem independence and portability which tackle the disadvantage of dependencies between clients and the implementation classes on an abstraction.

To layer your subsystem. Use façade to define an entry point to each subsystem level. If subsystems are dependent, then you can simplify the dependencies between them by making them communicate with each other solely through their facades.

Collaborations

  • Clients communicate with the subsystem by sending request to Façade, which forwards them to the appropriate subsystem object(s). Although the subsystem objects perform the actual work, the façade may have to do work of its own to translate its interface to subsystem interfaces.
  • Clients that user the façade don’t have to access its subsystem objects directly.

Consequences

The Façade Patterns offers the following benefits:

  •  It shields client from subsystem components, thereby reducing the number of objects that clients deal with and making the subsystem easier to use.
  • It promotes weak coupling between the subsystem and its clients.

Recommended Books

  

Related Posts

  • Observer pattern
  • What is Design pattern ?
  • Design pattern – Service Locator
  • Singleton

Filed Under: Design Patterns

Reader Interactions

Comments

  1. Cira Garon says

    May 28, 2011 at 5:43 pm

    It’s really a nice and helpful piece of information. I’m glad that you shared this helpful info with us. Please keep us informed like this. Thanks for sharing.

    Reply
  2. Fallon Gean says

    May 29, 2011 at 12:59 am

    Thanks for an idea, you sparked at thought from a angle I hadn’t given thoguht to yet. Now lets see if I can do something with it.

    Reply

Leave a Reply Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

FOLLOW US ONLINE

  • View J2eereference-166104970118637’s profile on Facebook
  • View j2eereference’s profile on Twitter
  • View j2eereference’s profile on LinkedIn

Subscribe by email

Recent posts

  • Java Buzzwords
  • Anonymous Inner Class in Java
  • Network Programming – java.net Package
  • Java Regular Expressions
  • Method Local Inner Class in Java
  • URL Processing in Java
  • Iterator Design Pattern Implementation using Java
  • Strategy Design Pattern Implementation using Java
  • Decorator Design Pattern
  • Adapter Design Pattern Implementation using Java
  • JSF Composite Components
  • JSF UI Components
  • What is JavaServer Faces (JSF)?
  • GOF Design Patterns
  • History and Need for Design Patterns

Footer

Core Java
Design Patterns
JSP
Servlets
HTML
Building Tools
AJAX
SCJP
jQuery
Testing
Spring
UML
Struts
Java Centers
Java Training
Home
About Us
Contact Us
Copyright © j2eereference.com. All right reserved.