Facade Design Pattern
The facade design pattern allows us, to provide a simplified interface from multiple class libraries. It provides a simple interface that hides the complexity of the class libraries being used.
UML Class diagram
For example, if the client code needs to access three different class libraries for a single functionality, instead of having the client code accessing those 3 class libraries, we can just create another class, that calls the required class libraries and have the client access only the class that you have created. The result is a simplified interface for the client and the client will not need to know the details of the actual (three) class libraries.
Real World Examples for Facade Pattern A MortgageApplication object, which provides a simplified interface to a large subsystem of classes measuring the credit worthiness of an applicant.
Implementation of above example in C#.Net
Create Customer class,
Create subsystem1 (Library1 from class diagram),
Create subsystem2 (Library2 from class diagram),
Create subsystem3 (Library3 from class diagram),
Now, create a Façade class,
Create a client to use above implemented façade class (Mortgage),
Output
test customer applies for $2,000,000.00 loan
Check bank for test customer
Check bad loans for test customer
Check credit for test customer
'test customer' has been Approved
Common mistakes while implementing facade pattern
In my experience the common mistakes I have seen are,
UML Class diagram
For example, if the client code needs to access three different class libraries for a single functionality, instead of having the client code accessing those 3 class libraries, we can just create another class, that calls the required class libraries and have the client access only the class that you have created. The result is a simplified interface for the client and the client will not need to know the details of the actual (three) class libraries.
Real World Examples for Facade Pattern A MortgageApplication object, which provides a simplified interface to a large subsystem of classes measuring the credit worthiness of an applicant.
Implementation of above example in C#.Net
Create Customer class,
public class Customer { private string _name; public Customer(string name) { _name = name; } public string Name { get { return _name; } } }
Create subsystem1 (Library1 from class diagram),
namespace DesignPatterns.Library1 { public class Credit { public bool HasGoodCredit(Customer c) { Console.WriteLine("Check credit for " + c.Name); return true; } } }
Create subsystem2 (Library2 from class diagram),
namespace DesignPatterns.Library2 { public class Bank { public bool HasSufficientSavings(Customer c, int amount) { Console.WriteLine("Check bank for " + c.Name); return true; } } }
Create subsystem3 (Library3 from class diagram),
namespace DesignPatterns.Library3 { public class Loan { public bool HasBadLoans(Customer c) { Console.WriteLine("Check bad loans for " + c.Name); return false; } } }
Now, create a Façade class,
namespace DesignPatterns.Facade { public class Mortgage { private Bank _bank = new Bank(); private Loan _loan = new Loan(); private Credit _credit = new Credit(); public bool IsEligible(Customer cust, int amount) { Console.WriteLine("{0} applies for {1:C} loan\n", cust.Name, amount); bool isEligible = true; // Check creditworthyness of applicant if (!_bank.HasSufficientSavings(cust, amount)) isEligible = false; else if (_loan.HasBadLoans(cust)) isEligible = false; else if (!_credit.HasGoodCredit(cust)) isEligible = false; return isEligible; } } }
Create a client to use above implemented façade class (Mortgage),
private void btnFacade_Click(object sender, EventArgs e) { // Facade class Mortgage mortgage = new Mortgage(); // Evaluate mortgage eligibility of customer Customer customer = new Customer("test customer"); bool eligible = mortgage.IsEligible(customer, 2000000); Console.WriteLine("\n'" + customer.Name + "' has been " + (eligible ? "Approved" : "Rejected")); }
Output
test customer applies for $2,000,000.00 loan
Check bank for test customer
Check bad loans for test customer
Check credit for test customer
'test customer' has been Approved
Common mistakes while implementing facade pattern
In my experience the common mistakes I have seen are,
- Just for the sake of introducing a facade layer developers tend to create additional classes. Layered architecture is good, but assesses the need for every layer.
- Methods in facade layer have only one or two lines which calls the other components. If facade is going to be so simple, it invalidates its purpose and clients can directly do that by themselves.
- A controller is not a facade.
- Facade is ‘not’ a layer that imposes security and hides important data and implementation.
- Don’t create a facade layer in advance. If you feel that in future the subsystem is going to evolve and become complicated to defend that do not create a stub class and name it a facade. After the subsystem has become complex you can implement the facade design pattern.
- Subsystems are not aware of facade and there should be no reference for facade in subsystems.
- Makes a software library easier to use, understand and test, since the facade has convenient methods for common tasks
- Makes code that uses the library more readable, for the same reason
- Reduce dependencies of outside code on the inner workings of a library, since most code uses the facade, thus allowing more flexibility in developing the system
- Wrap a poorly-designed collection of APIs with a single well-designed API.
hi,very nice article.i have to learned for lot of information...hadoop training in chennai
ReplyDeleteYour blog is really useful for me. Thanks for sharing this informative blog. If anyone wants to get real time Oracle Training in Chennai reach FITA located at Chennai. They give professional and job oriented training for all students.
ReplyDeleteExcellent post!!! The future of .net application development is on positive note. It offers huge career prospects for talented professionals all over the world. Training on .net technology will ensure good salary package. .Net Course in Chennai
ReplyDeleteThank you so much for sharing this wonderful information, I find your content to be unique and genuine. Keep sharing article and this will help many in finding the best institute for Hadoop Training Chennai
ReplyDeleteNice examples about .net..Its really good.
ReplyDeleteSoftware Testing Training in Chennai | QTP Training in Chennai | Software Testing Training in Chennai
Hi, nice article, nice example for private, public class related Php training in chennai
ReplyDeleteNice information about the faced design pattern.Its very awesome..Thanks..Its very useful..
ReplyDeleteSelenium Training in Chennai | QTP Training in Chennai | Software Testing Training in Chennai | QTP Training in Chennai
Really awesome blog. Your blog is really useful for me. Thanks for sharing this informative blog. Keep update your blog.
ReplyDeleteRegards..
Software Testing Training Institutes in Chennai
Thanks for sharing this information. Salesforce is a cloud based CRM. Nowadays most of the multinational companies used this CRM for managing their customers. To know more details call 9841746595.
ReplyDeleteRegards..
Salesforce Training in Chennai
I am reading your post from the beginning, it was so interesting to read & I feel thanks to you for posting such a good blog, keep updates regularly.
ReplyDeleteRegards,
sas training in Chennai|sas course in Chennai|sas training institute in Chennai
This information is impressive; I am inspired with your post writing style & how continuously you describe this topic. After reading your post, thanks for taking the time to discuss this, I feel happy about it and I love learning more about this topic.
ReplyDeleteRegards,
Informatica training in chennai|Informatica courses in Chennai|Informatica institutes in Chennai
Thanks for sharing this information in here. As a fresher any one can also go for the below training programs.
ReplyDeleteJava Training
.Net Training
PHP Training
How good is it to do an Android Training in Chennai? Can someone suggest?
ReplyDeleteThanks for sharing your informative article on Hive ODBC Driver. Your article is very descriptive and assists me to learn whole concept in detail. Hadoop Training in Chennai | Big Data Training in Chennai
ReplyDeleteThanks for sharing this niche useful informative post to our knowledge, Actually SAP is ERP software that can be used in many companies for their day to day business activities it has great scope in future.
ReplyDeleteRegards,
SAP training in chennai|SAP courses in chennai|SAP institutes in chennai|SAP Course in Chennai
ReplyDeleteif you are looking for the Big Data Training in indore i would highly recommened you the ssi , they are the one the best education institute in indore
Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging…
ReplyDeleteRegards,
Python Training in Chennai|Python Courses in Chennai
Website are the only way to execute a company's projects to their visitors. And it is mandatory to maintain a responsive one as well. Your content explicitly states that. Thanks for sharing this worth able article here. Keep up this good work.
ReplyDeleteWeb designing course in chennai | Web design course | Web design training in chennai
Maharashtra Police Wireless HC ASI Recruitment 2016
ReplyDeleteknowledge from your web site.it's a reputable great report.......
UP Urdu Teacher Recruitment 2016
ReplyDeleteI Like your site because you have a good post on this blog....
Learning new technolgoy would help oneself at hard part of their career. And staying updated is the only way to survive in current position. Your content tells the same. Thanks for sharing this information in here. Keep blogging like this.
ReplyDeleteJAVA Training in Chennai | Mobile application testing training in Chennai | Hadoop course in chennai
Using big data analytics may give the companies many fruitful results, the findings can be implemented in their business decisions so as to minimize their risk and to cut the costs.
ReplyDeletehadoop training in chennai|big data training|big data training in chennai
This technical post helps me to improve my skills set, thanks for this wonder article I expect your upcoming blog, so keep sharing.
ReplyDeleteFita Chennai reviews
Hadoop Training in Chennai
Big Data Training in Chennai
This facade design pattern is very useful including the architecture is amazing.It is fully explained in programming way.Thanks for this.
ReplyDeleteJava Training in Chennai
Thanks for posting this information in this blog. .net programming concept is clearly explained. The facade design architecture helps in understanding the concept in a clear manner Loadrunner Testing Training in Chennai
ReplyDeleteNice..It's more informative about facade design. It provides a simple interface that hides the complexity of the class libraries being used.All the programs are solved easily..Update more blogs like this.
ReplyDeleteAndroid Training in Chennai
This blog explains Facade Design Pattern is a method that provide simplified interface from multiple class libraries. This hides the very large information and provide minimum information. All the methods of this blog explain clearly. Thank you very much for this blog.
ReplyDeleteInformatica Training in Chennai
thanks for sharing this kind of valuable information.
ReplyDeleteabout this .net course which is useful and unforgetable article.
CCNA Training in Chennai
I am learning now only facade design pattern , it is really nice and unique and it tells about the merits and demerits of this pattern it will be useful for me.
ReplyDeletedot net training in chennai
well said about UML class diagram with its code. clearly understood about your concepts. keep update.
ReplyDeleteLoadrunner Training in Chennai
You have clearly explained about facade design pattern..its more useful and informative to know about this design..Keep in blogging like this ..
ReplyDeleteLinux training in chennai
this blog clearly explains the concept of facade pattern and design. It is explained by simple interface with complex libraries. Coding helps in understanding the concept in a clear manner
ReplyDeletessis training in chennai
Very happy to see this blog. Gives a wonderful information with coded explanaion. Thank you for this blog. very useful to me.
ReplyDeleteInformatica Training in Chennai
This facade design pattern is awesome.It is to read and is easy to understanding format.
ReplyDeleteSharepoint developer training in chennai
Great... Excellent sharing.. This is very helpful for beginers. Read that provide me more enthusiastic. This helps me get a more knowledge about this topic. Thanks for this.
ReplyDeleteDotnet Training in Chennai
It is the best article to read this information.good topic to discuss this article.I am very enjoy to read this information.It is to get the inspiration for me to go to the next level.
ReplyDeleteandroid training in chennai
This blog is really informative. I gained more knowledge by reading your post. Thanks for providing us the useful information with us. Your blog is really helpful for me in attaining my knowledge in a right way.
ReplyDeleteSelenium Training in Chennai
Great blog..You have clearly explained how to install hadoop ..Step by step explanation is too good to understand..Its very useful for me to understand..Keep on sharing..
ReplyDeleteSAS training in chennai
Great blog..You have clearly explained about the concept..Step by step explanation is too good to understand..Its very useful for me to understand..Keep on sharing..
ReplyDeleteWeb designing training in chennai
A very nice guide. I will definitely follow these tips. Thank you for sharing such detailed article. I am learning a lot from you.
ReplyDeleteSAP training in Chennai
This blog is impressive and informative.It clearly explains about the concept and its techniques.Thanks for sharing this information.Please update this type of information
ReplyDeletesas Training in Chennai
Thanks for the good words! Really appreciated. Great post. I’ve been commenting a lot on a few blogs recently, but I hadn’t thought about my approach until you brought it up.
ReplyDeleteSEO training in Adyar
Informatica is one of the most trusted and effective ETL software which is known globally. Informatica is one data warehousing ETL tool. Informatica ha very go opportuities for job across the world.
ReplyDeleteinformatica training in chennai | informatica training institute in Chennai | informatica classes in Chennai
Big data is used extensively in MNC today as using big data leads to accurate decision making and there are is a huge demand for the big data analysts.
ReplyDeleteBig data training in Chennai | Hadoop training in Chennai | Big data training institute in Chennai
thanks for sharing about dotnet..
ReplyDeleteSEO training in hyderabad by experts in digital markeing And by prosessional experts in seo.All the training by placement and also guide by the professionals.SEO training in hyderabad
To keep ourselves up to date with the current trend is not an easy task in IT. But we can, through quality and worth able content like this. Thanks for sharing this web page. Please write more articles like this in future.
ReplyDeletePHP training in Chennai | PHP course in Chennai
Excellant post!!!. The strategy you have posted on this technology helped me to get into the next level and had lot of information in it.
ReplyDeleteSAS Training in Chennai | SAS Course in Chennai
nice posts..The strategy you have poted is excellent thank for sharing../
ReplyDeleteSAS Institute introduced the SAS Certified Professional Program,training proper understanding of how the SAS software works. Among the five certification programs that SAS Institute has come up with, SAS training can be considered as the entry point into the big data and the data analytics industry.
SAS online training in hyderabad
facade design pattern nice posts..
ReplyDeleteHadoop training in hyderabad.All the basic and get the full knowledge of hadoop.
hadoop training in hyderabad
Thanks for sharing such these examples on Dot net. This is really useful and continue sharing more about Dot net.
ReplyDeleteRegards,
DOTNET Training in Chennai | DOTNET course in Chennai | DOTNET Training Institute in Chennai
This post having niche information to make myself updated.
ReplyDeletesalesforce administrator training in chennai|Salesforce certification Training in Chennai
Thanks for sharing your ideas on mobile application.Really useful to me.Continue sharing more like this.
ReplyDeleteRegards,
Mobile Application Training in Chennai | Mobile Apps Testing Training | Mobile Application Testing Training
Thanks for sharing information to our knowledge, it helps me plenty keep sharing…
ReplyDeleteJava Training in Chennai | JAVA Course in Chennai
Hello Admin,
ReplyDeleteAwesome Post! I like writing style, how you describing the topics throughout the post. I hope many web reader will keep reading your post at the end, Thanks for sharing your view.
Regards,
DOT NET Training Institutes in Chennai|Best DOT NET Training in Chennai|dot net training institutes in chennai
Excellent post!!! Java is most popular and efficient programming language available in the market today. It helps developers to create stunning desktop/web applications loaded with stunning functionalities.Best Angularjs Training in Chennai
ReplyDeleteAngularJS Training in Chennai
Thank you for Sharing. We are the best erp software providers in chennai. For more details call +91 9677025199 or email us on info@bravetechnologies.in
ReplyDeleteerp in chennai
The best thing is that your blog really informative thanks for your great information!
ReplyDeleteerp providers in chennai
Thank you for Sharing.
ReplyDeleteJoin the APTRON .net training company | web development course | CCNA Training Center in India | AutoCAD training center | ERP SAP Institute in Delhi.
Wonderful information to posting.. Thank you.. Web Designing Training Institute in Chennai | Web Designing Training Institute in Velachery.
ReplyDeleteGreate pieces. Keep writing such kind of information regarding etl testing vacancies in hyderabad. Im really impressed by your post.
ReplyDelete
ReplyDeleteHELLO GUYS SEARCHING FOR BEST DIGITAL MARKETING SEO TRAINING IN INDORE THAN YOU COME TO THE RIGHT WHERE YOU GOT THE BEST DIGITAL MARKETING INSTITUTION HERE IN INDORE.
digital marketing training indore
Very Nice Blog Most Useful blog....
ReplyDeleteThank You For Sharing .....
Computer Training Offer
SEO Training Free Demo
Android Training Great Job Offer
After Effects Video Editing
Web Design Course
hi, i really enjoyed to read your article... thanks for sharing your valuable information and ideas... it is very helpful to me....
ReplyDeleteDot Net Training in chennai | Dot Net Training institute in chennai
Interesting and informative article.. very useful to me.. thanks for sharing your wonderful ideas.. please keep on updating..
ReplyDeleteWeb Designing Training Institute in Chennai | Web Designing Training Institute in Velachery.