This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes OO, Patterns, UML and Refactoring and the fly likes regarding facade pattern Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "regarding facade pattern" Watch "regarding facade pattern" New topic
Author

regarding facade pattern

Raj Kumar Bindal
Ranch Hand

Joined: Apr 15, 2006
Posts: 418
facade patterns exists for core java.As far as i have understood,suppose three classes A,B,C wants to make calls to three more classes E,F,G.So,A,B,C will render this task to some class D which will act as facade.
so,what is the use of facade patter that is class D here.According to me:
1. to assign the task which A,B,C were doing to a common class D.

Please let me know if there is any other use of facade pattern.

For core java,can we say :this pattern is more helpful if E,F,G are in different package than A,B,C,so we make a class D in package where E,F,G are and then access them.
Please make me clear.
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Facade usually provides a simplified API to clients. A single facade method might call several hidden implementation objects. The idea is to make life easier on callers. It's a little risky - you can go overboard and put "too much" business logic into the facade.

A caller can make one "large grained" call instead of several "fine grained" calls, which can be important with remote calls.

We can change the implementation behind the facade without changing the API presented by the facade.

I worked on one project where each subsystem had a team of people and a facade. When I needed a new API from another team, they could update the facade with test code in a few minutes, then go design the implementation. Can't say I'd recommend this, but it worked nicely for a time.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Raj Kumar Bindal
Ranch Hand

Joined: Apr 15, 2006
Posts: 418
Hi Stan,
Thanks for your reply.
As you told,this pattern exists to make caller's life easy.I agree with that but if we see closely atleast one call is getting made extra.
Suppose,Class A was making call to Classes B and C.so,total were two calls.
But in case of facade,a call which will be made from A to facade will be extra,and facade will be calling B and C.So,total 3 calls.
Don't you think easiness is here on the cost of performance.And in case of session facade,it will be a bit more costly as there concept of business layer and gui layer comes into picture.
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
Originally posted by Raj Kumar Bindal:
Don't you think easiness is here on the cost of performance.And in case of session facade,it will be a bit more costly as there concept of business layer and gui layer comes into picture.

  • In the case of a regular fa�ade the addition of one (local) call is usually negligible compared to the gain in simplicity for the consumer (which now only depends on the fa�ade itself, rather than the multitude of objects that are behind the fa�ade) and ease of maintenance for the provider.
  • In the case of a Remote Fa�ade (a Session Fa�ade is basically a remote facade applied to a number Transaction Scripts) you actually end up with a performance gain as you are replacing multiple remote calls with a single remote call and multiple local calls - remote calls are much more costly in terms of time and resources than local calls.


  • Article: Understanding The Facade Pattern

    [Session Fa�ade/POJO Fa�ade] VS [Application Service]
    Nageswar Kakolla
    Ranch Hand

    Joined: Jan 16, 2006
    Posts: 71
    Hi there,

    Also, Network calls are performance inefficient since time taken and resources consumed over the network will add delay to the response vs mulitiple locals doesnt add much to delay and resources cost effective.

    Similar to IO latency, there is Network Latency which can be minimized by the Session Facade Pattern. As the definiton says, Session Pattern is derived/discovered from the experience to solve the problems faced over the course of applications.
    Nageswar Kakolla
    Ranch Hand

    Joined: Jan 16, 2006
    Posts: 71
    Hi there,

    Also, Network calls are performance inefficient since time taken and resources consumed over the network will add delay to the response vs mulitiple locals doesnt add much to delay and resources cost effective.

    Similar to IO latency, there is Network Latency which can be minimized by the Session Facade Pattern. As the definiton says, Session Pattern is derived/discovered from the experience to solve the problems faced over the course of applications.
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: regarding facade pattern
     
    Similar Threads
    long post IBM.158
    Threads and Synchronization examples
    Having trouble choosing a data structure
    Question from Whizlabs simulator
    Very interesting point in inheritance