问题描述
什么是上下文对象设计模式?
推荐答案
上下文是一个数据集,通常存储在Map或自定义类中,该类充当带有登录器和修饰符的结构.它用于维持状态和在系统中共享信息. 请参阅此PDF以获取Indepth Description .尽管可以用于高效和有效的数据共享,但您应该注意,许多人对Context模式持谨慎态度,如抗pattern .
其他推荐答案
它可能是httpsession对象:您的属性基本上是带有字符串键和对象元素的映射.这提供了HTTP请求之间的状态信息.另一个示例是ServletRequest,它在Servlet之间提供状态信息.
其他推荐答案
请参阅您可以解释上下文设计模式?用于对模式的详尽描述.
我在那里的帖子也解释了为什么它不是反模式 - 但它的of脑实现是.
问题描述
what is context object design pattern ?
推荐答案
A Context is a collection of data, often stored in a Map or in a custom class which acts as a struct with accessors and modifiers. It is used for maintaining state and for sharing information within a system. See this PDF for an indepth description. Though it can be used for efficient and effective data sharing, you should note that many are wary of the Context pattern as an anti-pattern.
其他推荐答案
An example for it might be the HttpSession object: you have attributes which is basically a map with String keys and Object elements. This provides state information between http requests. Another example is the ServletRequest which provides state information between Servlets.
其他推荐答案
See Can you explain the Context design pattern? for a thorough description of the pattern.
My post there also explains why it's not an anti-pattern - but the botched implementation of it is.