门面与商务代表模式的区别 [英] difference between facade and business delegate pattern

查看:119
本文介绍了门面与商务代表模式的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

门面与业务委托设计模式有什么区别?不是用来隐藏客户端的业务逻辑吗?

解决方案

代表团站在客户端和实际执行之间,通常从客户端隐藏/过滤/增强实现的某些功能。



Facade正在提供一个课程粒度的API,隐藏更复杂的逻辑和/或协调,通常捆绑几个一起工作的实现,通常为客户端提供便利。



来自java的每个示例:



委托: Collections.unmodifiableList()返回一个List,它保留对原始列表的引用,并为所有方法委托它,但如果调用其mutator方法,则抛出异常。



Facade:如果您曾经看到打印一个java DOM XML文档,第一个很薄你所做的是创建一个实用方法来隐藏所有的丑陋 - 该方法可以被认为是一个立面。


What is the difference between facade and business delegate design pattern. Aren't both 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.

这篇关于门面与商务代表模式的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆