开发者

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开发者_运维技巧?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜