此类项目类型的最佳代码组织
我有一组参数和系数。
它看起来像这样:
param1
{
Name:blabla;
PossibleValues:[{'lalalla1',0.9},{'lalala2',0.8},{'lalal3',0.7},{'lallal4',1.0}];
// where lalalla1 is name, 0.9 is coefficient
}
逻辑如下(规则集):
当 param1
的值为 lalala2 时,param2
的值只能是 'dsfsd'
当 的值为>param3
是“dsfsda”,则 param4
不存在。
当 param4
的值为“dsafsad”时,我们使用该公式:
Sum = param2.value.coeff*param6.value.coeff
依此类推。
对于此类任务类型,最佳的代码组织是什么?对于 UI,我想使用 knockoutjs,因为我有很多依赖元素。但我还将为业务逻辑和 UI 做单独的层并编写一些测试。我想要实现的另一件事是声明性规则。您对 Rx 有何看法?它能帮助我吗?或者你知道其他很酷的库吗?
I have a set of parameters and coefficients.
It looks like this:
param1
{
Name:blabla;
PossibleValues:[{'lalalla1',0.9},{'lalala2',0.8},{'lalal3',0.7},{'lallal4',1.0}];
// where lalalla1 is name, 0.9 is coefficient
}
and logic like this(set of rules):
When value of param1
is lalala2 then value of param2
could be only 'dsfsd'
When value of param3
is 'dsfsda' then param4
doesnt exists.
When value of param4
is 'dsafsad' then we use that formula:
Sum = param2.value.coeff*param6.value.coeff
And so on.
What is best code organization for such task types? For UI i want use knockoutjs because of i have many dependency elements. But also i am going to do separate layer for business logic and UI and write some tests. Another thing which i want implement is declarative rules. What do you think about Rx? Could it help me? Or do you know any other cool libs?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它只是前两个参数,但您需要的模式是相同的。 http://jsfiddle.net/photo_tom/39b9d/4/
您想要实现 dependentObservable 函数如 http://knockoutjs.com/documentation/dependentObservables.html
我认为这回答了您的问题,如果没有,请发表评论。
It is only the first two parameters, but the pattern you need is the same. http://jsfiddle.net/photo_tom/39b9d/4/
You want to implement dependendObservable functions as described on http://knockoutjs.com/documentation/dependentObservables.html
I think this answers your question, if not, please leave comment.