Changes

Jump to: navigation, search

Facade

1,974 bytes added, 11:38, 19 March 2007
no edit summary
== Facade Pattern ==
The Facade Pattern is used to consolidate numerous complicated objects and function calls in a single interface. It does not necessarily encapsulate the objects behind the facade, as it commonly allows the client to work directly with the object.
 
A facade is like a house. Someone walking by the house sees the exterior and knows the functionality contained within the house (shelter, kitchen, bathroom, bedrooms, etc), but does not know how they are set up or laid out (ie implemented). The person walking by can approach the house and interact with its functionality through the front door, which is the single point of access to that which is contained within the house (ie sub-system).
== UML Example ==
<center>[[Image:FacadeDesignPattern.png]]</center><br/>
[http://en.wikipedia.org/wiki/Image:FacadeDesignPattern.png|Wikipedia, used under GNU FDL]
== Code Examples ==
=== Java ===
[http://www.fluffycat.com/Java-Design-Patterns/Facade/|Java Design Patterns Facade]
<pre>
public class FacadeCuppaMaker {
boolean teaBagIsSteeped;
public FacadeCuppaMaker() {
System.out.println(
"FacadeCuppaMaker ready to make you a cuppa!");
}
public FacadeTeaCup makeACuppa() {
FacadeTeaCup cup = new FacadeTeaCup();
FacadeTeaBag teaBag = new FacadeTeaBag();
FacadeWater water = new FacadeWater();
cup.addFacadeTeaBag(teaBag);
water.boilFacadeWater();
cup.addFacadeWater(water);
cup.steepTeaBag();
return cup;
}
}
</pre>
=== C++ PHP5 ===[http://www.devshed.com/c/a/PHP/Introducing-the-Facade-Pattern-in-PHP-5/2/|DevShed Introducing Facade Pattern in PHP5]<pre>// define 'CompressContentFacade' classclass CompressContentFacade{ public static function stripContent($content){ // remove new lines from content $strippedContent=StripContent::stripString($content); // compress content by using GZIP algorithm $gzippedContent=GzipContent::compressString($strippedContent); return $gzippedContent; }}</pre>
=== C# .NET ===
=== Apache Tomcat ===
[http://www.google.com/codesearch?hl=en&q=show:hGyxCO8zbbo:dtgwsf4Jsds:mEr-jpM3hx4&sa=N&ct=rd&cs_p=http://download.nextag.com/apache/tomcat/tomcat-5/v5.5.17/src/apache-tomcat-5.5.17-src.tar.gz&cs_f=apache-tomcat-5.5.17-src/connectors/coyote/src/java/org/apache/coyote/tomcat4/CoyoteRequestFacade.java|Apache Excalibur Facade Class Code (via Google! Code Search)]<br/>
[http:<p>Serves to wrap the ServeltRequest object<//www.google.com/codesearch?hl=en&q=show:hGyxCO8zbbo:dtgwsf4Jsds:mEr-jpM3hx4&sa=N&ct=rd&cs_p=http://download.nextag.com/apache/tomcat/tomcat-5/v5.5.17/src/apache-tomcat-5.5.17-src.tar.gz&cs_f=apache-tomcat-5.5.17-src/connectors/coyote/src/java/org/apache/coyote/tomcat4/CoyoteRequestFacade.java|Apache Excalibur Facade Class Code (via Google! Code Search)]p><pre>/*
* Copyright 1999-2004 The Apache Software Foundation
*
[http://www.google.com/codesearch?hl=en&q=show:hGyxCO8zbbo:dtgwsf4Jsds:mEr-jpM3hx4&sa=N&ct=rd&cs_p=http://download.nextag.com/apache/tomcat/tomcat-5/v5.5.17/src/apache-tomcat-5.5.17-src.tar.gz&cs_f=apache-tomcat-5.5.17-src/connectors/coyote/src/java/org/apache/coyote/tomcat4/CoyoteRequestFacade.java|Apache Tomcat CoyoteRequestFacade Class Code (via Google! Code Search)]<br/>
[http://www.dofactory.com/Patterns/PatternFacade.aspx#_self1|Facade Design Pattern in C# and VB.NET]
[http://www.devshed.com/c/a/PHP/Introducing-the-Facade-Pattern-in-PHP-5/2/|DevShed Introducing Facade Pattern in PHP5]
[http://www.fluffycat.com/Java-Design-Patterns/Facade/|Java Design Patterns Facade]
1
edit

Navigation menu