你可以解释上下文设计模式吗? [英] Can you explain the Context design pattern?
本文介绍了你可以解释上下文设计模式吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经开始阅读上下文设计模式。这是我从文本中理解的:
-
你有一个包含所有变量的地图
-
你将它传递给需要它的人,所以你不必发送所有变量作为方法参数
我是否得到?
解决方案
p>
然而,我也认为这是更多的避免反模式。了解为什么此处。
另请参阅德米特法案
I've started to read about the Context design pattern. Here's what I understood from the text :
you have a map containing all your variables
you pass it around to whoever needs it, so that you won't have to send all the variables as method parameters
Did I "get" it?
解决方案
I think you got it.
However, I also think it is more of an anti-pattern to be avoided. See why here.
See also Law Of Demeter
这篇关于你可以解释上下文设计模式吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文