Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference between the facade and the business delegate pattern

 
geeta lalchandani
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the difference between the facade and the business delegate pattern?
as per my understanding.. both act as a layer. between the presentation and the business layer..
 
Manesh Kumar
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not a servlet question.
I think it should be under "OO, Patterns, UML and Refactoring".
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Business Delegate *is* a Facade. The Facade pattern is much more general, though - it is not at all restricted to be used as a layer between presentation and business layer, for example.

Many of the "J2EE patterns" are in fact variations and/or specializations of the original GoF patterns.
 
Mr. C Lamont Gilbert
Ranch Hand
Posts: 1170
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A Facade is not a layer. Its a fake layer. Hence the name, facade. It only looks like a layer from the outside, but thats just an illusion. It has no insides but to merely relay calls onto another object.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think we could define "layer" so Facade could be one. Or not.

The intent of Facade is to provide a unified and simplified API to a set of, well, less simple objects. My best experience with it was when we had several teams building components in parallel. When I needed a new API from the Contract team they could put a new method on their Facade and make it return some canned value that I could test with in minutes. Then they could huddle and design a real implementation at their leisure. I never had to see all the little implementation objects they had inside their component.

The intent of Business Delegate is to hide all the complexity of remote calls. They often double up as service locators. If I build an EJB server I can give clients a POJO delegate that they can call like any other object without knowing a thing about EJB remote calls. I use a vendor product with business delegates with multiple protocol implementations - local calls, remote EJB, proprietary raw socket protocol, XML/HTTP, etc.

Both are focused on making life easier for clients. If you write all the code from end to end that may not seem important. If you publish an API for everyone in the Enterprise to call, ease of ouse may make or break acceptance.

They're just good OO stuff some times, too. I would not be surprised if the "information hiding" value could make either or both worth while in many systems, even if I write the whole thing solo.
 
Ramen Chatterjee
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree completely with Stan. Just a couple of my own thoughts to expand on this (please tell me if you disagree).

Facade presents a simplifed view of a subsystem. It does not have to expose all of the subsystem, and clients can still access the subsystem directly if they desire. The common way people think of Facades (in J2EE anyway) is a session bean.

Business delegate protects a client from aspects of the system that are not business logic, eg the remoteness of a session bean. This makes the business delegate a client side pattern. In terms of implementation it may well look very similar to the thing it is protecting the client from, but may layer in other services such as caching.

Regards

Ramen
 
Peter Hu
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the structure perspect, I don't see much differency between them. They just describe similar things in different contexts. In J2EE, business delegate does sound better than facade.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see them on opposite ends of the remote protocol pipe. A facade might well have a business delegate.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic