• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

Design Pattern Facade  RSS feed

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all, I'm starting to read the book Design Patterns in Java but do not quite understand the Facade pattern,
someone could help me with a little more information about this pattern, they are appreciated.
 
Bartender
Posts: 4179
22
IntelliJ IDE Java Python
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The simplest way to think of the Facade pattern is as a wrapping of a complex or multi-step process into a simpler to use interface.

Let's say I have a library which moves the mouse around the screen. It might have classes / methods which look like this:


And you could then use that interface to simulate a drag-and-drop process:


That isn't too bad, and since you know the users of your library will use it a lot, you could publish the snippet somewhere as a recipe. Or, you could write a Facade that makes the process easier for the end user:


Then when it comes time to use your library to drag something on screen, you can replace the 14 lines of code in the drag sample above with this:


The Facade here doesn't add anything new to the scenario, it just wraps current functionality in a way easier to digest and figure out. It would make your code easier to interface with, and cause less bugs in the applications which use your library.
 
Anything worth doing well is worth doing poorly first. Just look at this tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!