Vyoms OneStopTesting.com - Testing EBooks, Tutorials, Articles, Jobs, Training Institutes etc.
OneStopGate.com - Gate EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
OneStopMBA.com - MBA EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
OneStopIAS.com - IAS EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
OneStopSAP.com - SAP EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
OneStopGRE.com - of GRE EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
Bookmark and Share Rss Feeds

Design Patterns - Facade Pattern | Articles | Recent Articles | News Article | Interesting Articles | Technology Articles | Articles On Education | Articles On Corporate | Company Articles | College Articles | Articles on Recession
Sponsored Ads
Hot Jobs
Fresher Jobs
Experienced Jobs
Government Jobs
Walkin Jobs
Placement Section
Company Profiles
Interview Questions
Placement Papers
Resources @ VYOMS
Companies In India
Consultants In India
Colleges In India
Exams In India
Latest Results
Notifications In India
Call Centers In India
Training Institutes In India
Job Communities In India
Courses In India
Jobs by Keyskills
Jobs by Functional Areas
Learn @ VYOMS
GATE Preparation
GRE Preparation
GMAT Preparation
IAS Preparation
SAP Preparation
Testing Preparation
MBA Preparation
News @ VYOMS
Freshers News
Job Articles
Latest News
India News Network
Interview Ebook
Get 30,000+ Interview Questions & Answers in an eBook.
Interview Success Kit - Get Success in Job Interviews
  • 30,000+ Interview Questions
  • Most Questions Answered
  • 5 FREE Bonuses
  • Free Upgrades

VYOMS TOP EMPLOYERS

Wipro Technologies
Tata Consultancy Services
Accenture
IBM
Satyam
Genpact
Cognizant Technologies

Home » Articles » Design Patterns - Facade Pattern

Design Patterns - Facade Pattern








Article Posted On Date : Monday, January 25, 2010


Design Patterns - Facade Pattern
Advertisements

Have you learned Design Patterns?  You probably need it on your resume and they will improve your coding.  This article will demonstrate another simple Design Pattern called the Facade Pattern.

This is the second in a series of articles on Design Patterns.  The first article covered the Singleton Pattern, which is a Creational Pattern.  This article will cover the simplest Structural pattern, called the Facade pattern.  The purpose of this pattern is to hide the complexity of dealing with the methods, etc., of several classes, and present a simple interface for the calling application.  You can view the next article on Design Patterns made simple by clicking Strategy Pattern,

In this article, I will show three of the numerous service classes I have in an application that I am currently working on.  Each of the three classes have multiple methods.  Each of the classes could be called from the main class or module in VB.NET (console application).  However, it is confusing to start off in a main driving method instantiating objects and calling the myriad methods that are involved in the processing of this application.  So to keep the "top down" look of the application simple, I have created a Process Class, using the Facade Pattern, to hide the complexity of the application from the main driving level.  

Shown below, is the UML diagram of the three classes and the relationship to the Facade (Process) Class.  You can see from this partial diagram that there will be multiple classes and multiple methods within the classes.

UML Diagram


Since I wrote the first article using VB.NET, I thought I would shift to C# for this one.  I don't want to show partiality.  First, I will show the code for the three service classes.  The first service class is for downloading and uploading files from/to FTP sites.  The shell code for this class is shown below, and a simple call to the constructor will invoke the dowlnloading of files.  Obviously the processing classes are oversimplified, but they are not the object of this article.

   public class FTPHandler
   {
      FTPLib ftp;
      
private string ftpURL;
      
private string ftpPW;
      
private string ftpUID;
      
private string dataDir;

      
public FTPHandler()
      {
         ftpUID = GetSettings(
"FTPURL");
         ftpURL = GetSettings(
"FTPUID");
         ftpPW = GetSettings(
"FTPPassword");
         dataDir = GetSettings(
"FTPDIR");

         ftp =
new FTPLib(ftpURL, ftpUID, ftpPW);
         ftp.DownLoadFiles(
"*.PGP", dataDir);
      }
// constructor
   }

Next I will a Zip file handling class.  

   public class ZipProcessing
   {
      
private string zipDirectory;
      
private string zipFileName;
      
private ZipComponent zip;

      
private ZipProcessing()
      {
         zipDirectory = GetSettings(
"ZipDir");
         zipFileName = GetSettings(
"ZipFile");
         zip =
new ZipComponent(zipDirectory, zipFileName);
         zip.ZipFiles();
      }
// constructor: ZipProcessing
   } // class

I will not flesh out a copy of the ProcessFiles class, as it will add nothing to the content of the article.  Now, I wll show a copy of the Process Class, which is the Facade.

   public class Process
   {
      
public CallProcessingMethods(string procType)
      {
        
switch (procType)
         {
            
case "FTP":
              
FTPHandler ftp = new FTPHandler();
              
break;
            
case "ZIP":
              
ZipProcessing zip = new ZipProcessing();
              
break;
            
case "PF":
               FileProcessor fp =
new FileProcessor();
              
break;
         }
// switch
      } // Constructor
   }

The main program would call the Process class, passing a string to designate the type of processing to perform.  The whole purpose  of the Facade (Process Class) is to hide any of the details of the processing classes from the main program.  Although the processing classes shown above are very simple, they could be quite complex, but the Facade pattern hides that complexity from the main program.

Have you tried our newest product, Visual Class Organizer?  You'll be amazed how easy it  is to keep the code in your code windows organized.  TRY IT FREE FOR 30  DAYS BY CLICKING HERE.



If you are developing in C# and haven't tried CSharpCompleter, you are wasting valuable  time typing hundreds of braces {} daily needlessly.  Try CSharpCompleter for 30  DAYS FREE.







Sponsored Ads



Interview Questions
HR Interview Questions
Testing Interview Questions
SAP Interview Questions
Business Intelligence Interview Questions
Call Center Interview Questions

Databases

Clipper Interview Questions
DBA Interview Questions
Firebird Interview Questions
Hierarchical Interview Questions
Informix Interview Questions
Microsoft Access Interview Questions
MS SqlServer Interview Questions
MYSQL Interview Questions
Network Interview Questions
Object Relational Interview Questions
PL/SQL Interview Questions
PostgreSQL Interview Questions
Progress Interview Questions
Relational Interview Questions
SQL Interview Questions
SQL Server Interview Questions
Stored Procedures Interview Questions
Sybase Interview Questions
Teradata Interview Questions

Microsof Technologies

.Net Database Interview Questions
.Net Deployement Interview Questions
ADO.NET Interview Questions
ADO.NET 2.0 Interview Questions
Architecture Interview Questions
ASP Interview Questions
ASP.NET Interview Questions
ASP.NET 2.0 Interview Questions
C# Interview Questions
Csharp Interview Questions
DataGrid Interview Questions
DotNet Interview Questions
Microsoft Basics Interview Questions
Microsoft.NET Interview Questions
Microsoft.NET 2.0 Interview Questions
Share Point Interview Questions
Silverlight Interview Questions
VB.NET Interview Questions
VC++ Interview Questions
Visual Basic Interview Questions

Java / J2EE

Applet Interview Questions
Core Java Interview Questions
Eclipse Interview Questions
EJB Interview Questions
Hibernate Interview Questions
J2ME Interview Questions
J2SE Interview Questions
Java Interview Questions
Java Beans Interview Questions
Java Patterns Interview Questions
Java Security Interview Questions
Java Swing Interview Questions
JBOSS Interview Questions
JDBC Interview Questions
JMS Interview Questions
JSF Interview Questions
JSP Interview Questions
RMI Interview Questions
Servlet Interview Questions
Socket Programming Interview Questions
Springs Interview Questions
Struts Interview Questions
Web Sphere Interview Questions

Programming Languages

C Interview Questions
C++ Interview Questions
CGI Interview Questions
Delphi Interview Questions
Fortran Interview Questions
ILU Interview Questions
LISP Interview Questions
Pascal Interview Questions
Perl Interview Questions
PHP Interview Questions
Ruby Interview Questions
Signature Interview Questions
UML Interview Questions
VBA Interview Questions
Windows Interview Questions
Mainframe Interview Questions


Copyright © 2001-2020 Vyoms.com. All Rights Reserved. Home | About Us | Advertise With Vyoms.com | Jobs | Contact Us | Feedback | Link to Us | Privacy Policy | Terms & Conditions
Placement Papers | Get Your Free Website | IAS Preparation | C++ Interview Questions | C Interview Questions | Report a Bug | Romantic Shayari | CAT 2020

Fresher Jobs | Experienced Jobs | Government Jobs | Walkin Jobs | Company Profiles | Interview Questions | Placement Papers | Companies In India | Consultants In India | Colleges In India | Exams In India | Latest Results | Notifications In India | Call Centers In India | Training Institutes In India | Job Communities In India | Courses In India | Jobs by Keyskills | Jobs by Functional Areas

Testing Articles | Testing Books | Testing Certifications | Testing FAQs | Testing Downloads | Testing Interview Questions | Testing Jobs | Testing Training Institutes

Gate Articles | Gate Books | Gate Colleges | Gate Downloads | Gate Faqs | Gate Jobs | Gate News | Gate Sample Papers | Gate Training Institutes

MBA Articles | MBA Books | MBA Case Studies | MBA Business Schools | MBA Current Affairs | MBA Downloads | MBA Events | MBA Notifications | MBA FAQs | MBA Jobs
MBA Job Consultants | MBA News | MBA Results | MBA Courses | MBA Sample Papers | MBA Interview Questions | MBA Training Institutes

GRE Articles | GRE Books | GRE Colleges | GRE Downloads | GRE Events | GRE FAQs | GRE News | GRE Training Institutes | GRE Sample Papers

IAS Articles | IAS Books | IAS Current Affairs | IAS Downloads | IAS Events | IAS FAQs | IAS News | IAS Notifications | IAS UPSC Jobs | IAS Previous Question Papers
IAS Results | IAS Sample Papers | IAS Interview Questions | IAS Training Institutes | IAS Toppers Interview

SAP Articles | SAP Books | SAP Certifications | SAP Companies | SAP Study Materials | SAP Events | SAP FAQs | SAP Jobs | SAP Job Consultants
SAP Links | SAP News | SAP Sample Papers | SAP Interview Questions | SAP Training Institutes |


Copyright ©2001-2020 Vyoms.com, All Rights Reserved.
Disclaimer: VYOMS.com has taken all reasonable steps to ensure that information on this site is authentic. Applicants are advised to research bonafides of advertisers independently. VYOMS.com shall not have any responsibility in this regard.