What is the difference between facade and business delegate design pattern?
Aren't both of them used for hiding business logic from the client?

- 771
- 9
- 30

- 3,083
- 7
- 35
- 59
1 Answers
Delegation is standing between the client and the actual implementation, usually hiding/filtering/augmenting certain functionality of the implementation from the client.
Facade is providing a course-grained API hiding more complex logic and/or coordination, usually bundling up several implementations that work together, and usually as a convenience to the client.
Examples of each from java:
Delegation: The Collections.unmodifiableList()
returns a List that keeps a reference to the original List and delegates to it for all methods, but throws Exceptions if its mutator methods are called.
Facade: If you've ever seen the ridiculous amount of code required to print a java DOM XML document, the first thing you do is create a utility method to hide all the ugliness - that method could be considered a facade.
-
Thanks, but can you please elaborate Facade. – Ankit Sep 02 '11 at 10:34
-
2For an example of facade, say you have an entitlement service which exposes a facade to check for entitlements.. So for the user of the service it is as easy as calling just one method and get to know the entitlement status. However, the service might be internally querying from a db or a cache the entitlement status and processing the roles et-all for the user thereby providing the user of the service an easy to use facade and hiding the complexity – Scorpion Sep 03 '11 at 07:04
-
So, is it correct to say they are basically equal except facade mixing multiple "workhorse" classes as opposed to Delegation exposing one class, albeit beefed-up? – Jun 15 '17 at 15:00