违反业务规则和例外情况
有人可以帮我提供一篇文章的链接,或者一个包含链接的 SO 帖子的链接,说明为什么对带有异常的业务规则违规进行建模不是一个好主意。如果这本书可以在 Safari 上找到,我也很乐意提供对这本书和页面的参考,并且书中的摘录将是双倍的好处!
我在我看过的问题和答案中看到了很多很好的理由,但其他人需要一些更权威的东西(福勒/埃文斯联盟中的东西会很好)。
谢谢
Can someone help me with a link to an article, or a link to a SO post that contains a link, on why its not a good idea to model business rule violations with exceptions. I'd also be happy with a reference to a book and page, if the book was available on Safari, and an extract from the book would be double plus good!
I've seen plenty of good reasons in questions and answers I've looked at on SO, but others need something a little more authoritative (something in the Fowler/Evans league would be nice).
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
虽然我还没有完全阅读这些内容,但我认为这些链接(其中一个来自 Google 图书)应该对您有用,因为它们主要与 Ronald G. Ross 撰写的业务规则建模相关(brcommunity.com):
http://books.google.co.in/books?id=Uyv9hMOt6BsC&pg=PA72&lpg=PA72&dq=business+rule+violations&source=bl&ots=8fb5Vqgi3K&sig =DNUkrv4wNZTX755rVk2gv0upzUs&hl=en&sa=X&ei=QYsFT7ezEOf10gH68tmLAg&ved=0CFsQ6AEwCDgK#v=onepage&q=business%20rule%20violations&f=false
http://www.brcommunity.com/b335.php
Though I have not read these completely, I think these links (one of them is from Google Books) should be useful to you as they are mostly related to modelling business rules authored by Ronald G. Ross (brcommunity.com):
http://books.google.co.in/books?id=Uyv9hMOt6BsC&pg=PA72&lpg=PA72&dq=business+rule+violations&source=bl&ots=8fb5Vqgi3K&sig=DNUkrv4wNZTX755rVk2gv0upzUs&hl=en&sa=X&ei=QYsFT7ezEOf10gH68tmLAg&ved=0CFsQ6AEwCDgK#v=onepage&q=business%20rule%20violations&f=false
http://www.brcommunity.com/b335.php
我认为你不会在任何书中找到权威的答案。有些人会声称在 C# 中抛出异常的成本非常高。其他人(比如我)会告诉你不要担心它,除非你正在构建一个半实时系统。我一直在所有主要的企业级系统中抛出 RuleViolationExceptions,因为我发现这比让域中的每个方法都返回某种错误代码要好得多。事实上,我认为这是最佳实践,因此我已将其包含在我的 Silverlight Cookbook 项目中。
I don't think you'll find an authoritive answer in any book. Some people will claim throwing exceptions is very expensive in C#. Others (like me) will tell you to not worry about it, unless you're building a semi-realtime system. I've been throwing RuleViolationExceptions in all my major enterprise-class systems because I've seen that this works a lot better than having every method in you domain return some kind of error code. In fact, I think it's a best practice, so I've included this in my Silverlight Cookbook project.