违反业务规则和例外情况

发布于 2024-12-17 05:10:58 字数 217 浏览 4 评论 0原文

有人可以帮我提供一篇文章的链接,或者一个包含链接的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我偏爱纯白色 2024-12-24 05:10:58

我认为你不会在任何书中找到权威的答案。有些人会声称在 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文