Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

regarding facade pattern

 
Raj Kumar Bindal
Ranch Hand
Posts: 418
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Raj Kumar Bindal
Ranch Hand
Posts: 418
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2968
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
    Posts: 71
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Posts: 71
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic