我有一个类MasterData
,它的实例包含一些关于所有可能的小工具的一般信息。你知道吗
我还有另一个类CustomerData
,其实例包含:
MasterData
中相同小工具的链接CustomerData
构造函数采用以下参数:
链接非常简单,只需从客户文件中获取适当的ID并在主数据的适当字段中查找即可。在customer模块中提供了包含相关id(customer和master)的字段的名称。实际的链接是在CustomerData
构造函数中执行的。你知道吗
在我们提出新的、更复杂的匹配规则之前,一切都很顺利。每个匹配规则只适用于一个特定的客户,所以我想把所有可能的匹配规则放在每个客户模块中,然后让应用程序选择它想要使用的规则。但不幸的是,新的匹配规则要求对主数据进行操作,模块自然是一个“被动”对象,甚至没有到主数据的链接。你知道吗
我是否应该在以主数据实例和客户记录为参数的模块中创建全局函数,并返回主数据记录?你知道吗
或者我应该把匹配规则放在别处?你知道吗
一般来说。你知道吗
这不应该是一个模块。这不是错的。但这可能会让人困惑。你知道吗
考虑改变一些事情,这样你就有了这样的东西。你知道吗
那么。每个客户都有一个模块
这样,就可以在customer模块中使用
ThisCustomerData
实例。模块不是任何东西的参数;模块包含客户的代码。你知道吗客户安装的应用程序如下所示
现在,您可以从通用的应用程序构建客户特定的应用程序实例,再加上从客户的扩展模块导入的客户特定的覆盖。你知道吗
这样做的好处是允许更多的自由,因为您不局限于将模块插入类中。您正在使用module来包含一个类定义,它现在可以做任何事情。你知道吗
相关问题 更多 >
编程相关推荐