如何最好地处理跨平台/层的重复代码?

发布于 2024-07-29 23:57:47 字数 364 浏览 5 评论 0原文

我很好奇每个人如何处理跨多个平台/层的代码重复。

例如,在我们的应用程序中,我们有一个显示索赔的屏幕。 如果某个索赔满足某些条件,则该索赔被视为未决索赔,并且用户希望查看其列表中哪些索赔未决,因此应用程序中有一段代码可以执行此操作。

然后,我们还有完全独立于应用程序的报告,用户希望获得所有未决索赔的报告。 由于无法创建索赔实体并查看其是否在报告中突出,因此我们似乎必须有一些重复的代码。

您可以在数据库中拥有一个函数或其他东西来提供此信息和您的单段代码,但是您只能依赖数据库来实现业务逻辑,并且您必须为每个声明往返数据库您想在应用程序中查看,这不太理想!

那么,每个人都如何处理这样的情况?有什么我应该注意的最佳实践吗?

I'm curious about how everyone handles code duplication across multiple platforms/tiers.

As an example, in our application we have a screen that displays claims.
A claim is deemed to be outstanding if it satisfies certain critera and users want to see which claims are outstanding in their lists, so there is one piece of code in the application that does this.

We then also have reports that are entirely separate from the application, and users want reports of all their outstanding claims.
As there is no way to create a claim entity and see if it is outstanding from the report it seems that we necessarily have to have some duplication of code.

You could have a function or something in the database that provides this information and your single piece of code, but you're then solely relying on the db for business logic and you'd have to do a round trip to the db for each claim you want to check in the app, not exactly ideal!

So, how does everyone handle situations like this and are there any best practices I should be aware of?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

淡笑忘祈一世凡恋 2024-08-05 23:57:47

特别是在您的情况下,如果您的业务逻辑包含在业务域层中。 然后,您可以创建两个彼此独立地使用该业务域的应用程序。

查看 100,000 英尺的景观。

          DataProviders
               |
          BusinessDomain
          |           |
    Application   Reporting Services

Specifically in your case if your business logic is contained in a business domain tier. You could then create two Applications that consume that business domain independently of each other.

See 100,000 foot view.

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