有人可以解释一下转发和委托之间的区别吗?它们看起来很相似,但我一直无法找到转发的良好定义,所以我不确定我是否真的理解。
我们首先定义两个术语:
-
sender :
the object that sends a message/task to another object(the receiver)
-
receiver:
the object that receives a message/task from the sender
和...之间的不同转发 and 代表团是在转发 the receiver acts in its own context
而在代表团 the receiver acts on the behalf of the sender
.
这是一个很好的比喻博客文章 http://raganwald.com/2014/04/10/mixins-forwarding-delegation.html:
委托和转发非常相似。一个可能有助于区分它们的比喻是,想象一下收到一封电子邮件,要求您向有价值的慈善机构捐款一些钱。
- If you forward给朋友发邮件,朋友捐钱,朋友是捐出自己的钱并获得自己的税单。
- If you delegate回复你的会计师,会计师捐出你的钱交给慈善机构,您就会收到税单。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)