Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

difference between facade and business delegate pattern

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

like image 897
Ankit Avatar asked Feb 23 '23 02:02

Ankit


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.

like image 175
Bohemian Avatar answered Mar 02 '23 15:03

Bohemian