将业务规则与业务逻辑分离
我只是想知道如何将业务规则与业务逻辑分开的替代方案或设计模式,而不使用业务引擎(如果可能)。
已经有一个问题问这个主题,但每个答案似乎都没有具体答案,所以这是我的尝试。
例如,申请学校。
会有最低年龄、最高年龄、先决教育等规则。 一年后,学校会要求额外的规则,比如
头发颜色应该是特定类型, 高度, 手指的长度要有一定的长度, 他们听的音乐以及所有其他规则。
我怎样才能使应用程序适应系统上的这些变化。
i just want to know alternatives or design patterns of how I can separate business rules from business logic WITHOUT using a business engine if possible.
there is already a question that asked this subject but every answer seems to have no specific answer so here is my try.
for example, for an application to a school.
there would rules like the minimum age, the maximum age, prerequisite education and etc.
and then after a year, the school would ask for additional rules like
hair color should be of a specific type,
the height,
the length of fingers should be of a certain length,
the music they listen to and all that additional rules.
how can I make an application to be adaptable to these kind of changes on the system.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
业务逻辑和业务规则实际上只是描述同一事物的两种方式。
我建议你从两个角度思考你的问题。首先考虑将存在的业务对象。例如,具有年龄、身高等值的 Pupil 对象。然后考虑您想要应用的规则,例如验证特定年龄以上的所有学生都应有最低身高。您可以将验证作为业务对象的一部分或作为单独的对象来实现。没有正确或错误的答案,因为这取决于您试图解决的问题。
Business logic and business rules are really just two ways of describing the same thing.
I recommend you think about your problem from two perspectives. First think about the business objects that will exist. For example a Pupil object that has values such as age, height and so forth. Then think about rules that you would like to have applied, such as validating that all pupils over a certain age should have a minimum height. You could implement the validating as part of the business object or as a separate object in its own right. There is no right or wrong answer as it depends on the problem your trying to solve.