1

我是 ColdFusion 的新手并使用 ColdFusion MX (7),我有兴趣实施策略模式。但我不知道开始实施的最佳方式是什么。

4

3 回答 3

5

在 Google 上查找 ColdFusion 设计模式,您会找到几个站点。

同时希望这个有帮助(链接更新 04/01/2018) - https://web.archive.org/web/20150314004313/http://coldfusiondesignpatterns.org/strategy.html

于 2011-01-27T09:28:07.873 回答
0

我推荐 head First Design Patterns书。它涵盖了策略模式以及许多其他模式,它写得很好,在设计应用程序时会一次又一次地帮助你。

于 2011-01-27T09:50:06.750 回答
0

首先确定您的Context- 那是您要在其中执行策略的环境。如果这与您之前的问题有关,我建议 Product Detail 属于此类,并且可能这样编码:

<cfcomponent name="ProductDetail">
  <cffunction name="getOverview" returntype="any">
    <cfargument name="criteria"/>
    <!--- call strategy here --->
  </cffunction>
</cfcomponent>

采用这种方法而不是具有继承的类层次结构的原因是,如果 ProductDetail 具有问题的全局行为(即函数)。

第二步是确定似乎与搜索标准相关的各种策略。您可能需要在产品和标准策略之间进行映射练习,特别是如果两者之间的关系是多对多的。

于 2011-01-27T12:04:20.383 回答