参数化转换规则的对象模型
我之前问过类似的问题,但将其作为特定于语言的问题提出。我意识到我的问题出在建模层面。
我应该如何在对象模型中表示以下内容:
我有:
- 数据对象
- 参数对象
- 规则对象
规则指定如何修改它接收到的数据对象;它需要完整定义附加参数。规则可以使用其他规则(在内部引用它们,或者在参数对象中被告知这样做)。
该规则不是用某种需要有人解析的自定义语言编写的;相反,它只包含应该执行的代码。这听起来像是设计之前的实现解决方案,但它实际上是需求之一(系统用户是希望能够编写自己的规则并将其轻松添加到系统中的程序员)。
主要活动发生在数据对象、参数对象和规则对象相遇时;此时,数据对象被修改。
用户告诉系统他想要满足哪个规则、哪个参数、哪个数据对象,并期望取回修改后的数据对象。
更新:
数据对象示例:
所有数据对象都可以在逻辑上表示为 SQL 表。
数据对象 ID #7:一个 SQL 表
数据对象 ID #13:一个 SQL 表
参数对象示例:
所有参数对象都具有相同的布局:一个文本文件,其中每一行看起来像
=
参数对象 ID #52:
规则=“回归”
数据 ID = 7
Y =“成本”
X = '最大速度'
R =“成本估算错误”
参数对象#59:
规则=“平均”
数据 ID = 13
COLUMNS = '最小速度', '最大速度'
AVERAGE = '平均速度'
规则对象示例:
规则对象 'regression':
执行线性回归;名为“Y”和“X”的参数指定用作因变量和自变量的列名称;名为“R”的参数指定要添加到包含回归残差的表中的列名称。
规则对象“average”:
计算参数“COLUMNS”中列出的列中指定的数字的平均值,并将结果存储在参数“AVERAGE”中指定的列中。
I asked a similar question earlier, but posed it as a language-specific question. I realized that my issue is at the modelling level.
How should I represent the following in the object model:
I have:
- Data objects
- Parameter objects
- Rules objects
A rule specifies how to modify a data object it receives; it requires additional parameters to be fully defined. A rule may use other rules (either referring to them internally, or being told to do so in the parameter object).
The rule is not written in some custom language that someone needs to parse; rather it simply consists of the code that should be executed. This may sound like an implementation solution ahead of the design, but it's actually one of the requirements (system users are programmers who want to be able to write their own rules and add them to the system easily).
The main activity happens when a data object, a parameter object, and a rule object meet; at that time, the data object gets modified.
The user tells the system which rule, which parameter, and which data object he wants to meet, and expects to get back the modified data object.
UPDATE:
Examples of data objects:
All data objects can be logically represented as SQL tables.
Data object ID #7: a SQL table
Data object ID #13: a SQL table
Examples of parameter objects:
All parameter objects have the same layout: a text file, where each line looks like
<PARAMETER_NAME>
=<VALUE>
Parameter object ID #52:
RULE = 'regression'
DATA ID = 7
Y = 'cost'
X = 'maximum speed'
R = 'error in cost estimate'
Parameter object #59:
RULE = 'average'
DATA ID = 13
COLUMNS = 'min speed', 'max speed'
AVERAGE = 'avg speed'
Examples of rules objects:
Rule object 'regression':
Performs linear regression; parameters named 'Y' and 'X' specify column names to be used as dependent and independent variables; parameter named 'R' specifies the column name to be added to the table that will contain the residuals from the regression.
Rule object 'average':
Calculates the average of the numbers specified in columns listed in parameter 'COLUMNS', and stores the result in the column specified in parameter 'AVERAGE'.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将它们定义为 UML 构造型。为您的三种元类型创建一个元类。数据对象、参数对象和规则对象。将特定详细信息添加到元类,然后将元类的构造型应用到模型中的真实项目对象。
Define them As UML stereotypes. Create a metaclass for your three meta types. DataObject, ParameteObject, and RulesObject. Add the specific details to the metaclass, then apply that stereotype of the Metaclass to the real item objects in your model.