Published:
04 Sep 2006
|
Abstract
This article demonstrates the Facade design pattern with the help of Non-Software and Software examples such as the Web Service Facade.
|
|
by Vishal Patil
Feedback
|
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days):
28882/
56
|
|
|
Overview |
This article provides a brief introduction to Facade Design
Patterns. Facade Design pattern provides an easy to use interface to an
otherwise complicated collection of interfaces or subsystems. It makes things
easier by hiding the details of the implementation.
When designing good programs, programmers usually attempt to
avoid excess coupling between module/classes. Using this pattern helps to
simplify much of the interfacing that makes large amounts of coupling complex
to use and difficult to understand.
In a nutshell, this is accomplished by creating a small
collection of classes that have a single class (Facade) that is used to access
them.
The facade pattern is an object-oriented design pattern. A
facade is an object that provides a simplified interface to a larger body of
code, such as a class library. A facade can accomplish all of the following.
- It can make a software library easier to use and
understand since the facade has convenient methods for common tasks.
- It makes code that uses the library more readable for the
same reason.
- It can reduce dependencies of outside code on the inner
workings of a library since most code uses the facade. This allows for
more flexibility in developing the system.
- It can wrap a poorly designed collection of APIs with a
single well-designed API.
The following Non-software and software examples demonstrate
this pattern.
|
Non-Software examples |
In most of the Pizza centers, orders will be given through
phone calls with the customer interacting with the Customer service
representative. In this case, consumers do not have access to the Billing
system, Kitchen and delivery department. The customer service representative
acts as an interface and interacts with each of the departments involved in the
transaction and ensures that Pizzas are delivered to the consumer.
Figure 1
We can relate this non-software example against the facade
design pattern in the following way:
- Customer Service representative corresponds to the facade.
- Individual departments involved in the transaction
correspond to Sub-systems.
Another example we can consider is Emergency services. In
the event of fire we just inform an Emergency Service operator. The emergency
operator interacts with police, ambulance and fire services and dispatches
them. Here the client is shielded from individual emergency services.
|
Software examples |
Web Service Facade Solution Architecture (Refer to Figure 2
below) provides an example for Facade design pattern. In this architectural
solution, instead of rewriting legacy applications or customizing those with
middleware to connect to other applications one by one, this solution helps
create a "facade" for the legacy application. Other applications are
easily "plugged into" this facade. By modeling a legacy application
into its basic functions of create, read, update, and delete and then exposing
these functions as Web methods, the Web service facade solution allows other
applications to access legacy data by making use of common Web services through
standardized protocols. In this way, Facade decouples layers so that they do
not depend on each other which can make it easier to develop, to use and to
promote code re-use.
Figure 2
The JIT (Just in-Time) compilers that we use everyday to
process the Dotnet code is a prime example of the facade pattern. JIT compiler
performs several lower level functions before converting MSIL into native code,
such as verifying whether Microsoft intermediate language (MSIL) code can
access the memory locations, checking MSIL code is correctly generated because incorrect
MSIL can lead to a violation of the type safety rules, etc.
|
Conclusion |
Thus, Facade is a design pattern that hides the details and
complexities of the lower-level software services for which it is written,
making the service easier to use. In fact, the lower-level classes need not be
classes at all; they can be an API in the form of a code library or a Web
service.
A Facade also provides a unified entry point into the layers
of the software. This reduces the application's dependency on the software
service details and allows the Facade to hide future changes in the software
service itself.
|
References |
|
|
|
User Comments
Title:
123
Name:
123
Date:
2012-09-16 11:43:00 AM
Comment:
All industries need to improve aspects of vulnerability, these cases are not only reflected in the pizza above, a variety of small and medium-sized enterprises are also problems. |http://www.cocojersey.com
|
Title:
operator
Name:
services
Date:
2012-09-16 11:34:26 AM
Comment:
ugly graphics Name: Famous Coward Date: 1/31/2007 3:26:21 AM Comment: Next time, use better color schemes
|
Title:
Mr
Name:
Nilesh Gule
Date:
2012-07-16 11:06:18 AM
Comment:
Nice post. I recently demonstrated Facade design pattern using home loan as an example. http://www.nileshgule.com/2012/07/facade-design-pattern.html
|
Title:
Coder
Name:
sweeny
Date:
2010-05-04 7:28:22 AM
Comment:
simple explanation easy to understand, keep it up.
|
Title:
.net dev
Name:
Jac
Date:
2010-04-30 11:01:46 AM
Comment:
i like it... good introduction to facade.
|
Title:
Excellent Article
Name:
Santosh Pulate
Date:
2010-01-08 5:16:11 AM
Comment:
Article is very very simple and easy to understand. Thanks a lot for your help.
|
Title:
Article is Good
Name:
Vikas Muradia
Date:
2009-11-30 2:31:33 AM
Comment:
Article is simple and easy to understand the pattern, but an example is missing.
|
Title:
Good Article
Name:
Rakesh
Date:
2009-03-09 7:22:28 AM
Comment:
Good Article for initial understanding. Implementation would have helped here.
|
Title:
Fetching Article For Beginners
Name:
Rajesh Shah
Date:
2008-08-12 6:18:16 AM
Comment:
It's better for beginners as this gives good insights of facade.
|
Title:
Good Article
Name:
Hariom
Date:
2007-08-20 1:01:03 AM
Comment:
It's a good article for the beginners. Please expend it moree if you can.
|
Title:
ugly graphics
Name:
Famous Coward
Date:
2007-01-31 3:26:21 AM
Comment:
Next time, use better color schemes. These hurt my eyes so bad I gave the whole article a skip. =P
|
Title:
Programmer
Name:
Chakri
Date:
2006-12-27 7:37:48 AM
Comment:
The article provides the basic insight of the Facade Design Pattern. Appreciations to the writer.
|
Title:
Could have Extended more on Sofware Example for Facade
Name:
Ponnu
Date:
2006-09-07 6:29:07 AM
Comment:
Hi Vishal,
Really a nice article for begginers, you could have extended more on the Software example though.
Ponnu
|
|
Product Spotlight
|
|