gpt4 book ai didi

c# - 表模块和事务脚本之间的区别

转载 作者:行者123 更新时间:2023-11-30 14:37:47 25 4
gpt4 key购买 nike

我不明白 Martin Fowler 所说的这些模式之间有什么区别:

Transaction Script organizes business logic by procedures where each procedure handles a single request from the presentation.

Table Module a single instance that handles the business logic for all rows in a database table or view.

还有

You can organize your Transaction Scripts into classes in two ways. The most common is to have several Transaction Scripts in a single class, where each class defines a subject area of related Transaction Scripts. This is straightforward and the best bet for most cases. The other way is to have each Transaction Script in its own class (Figure 9.1), using the Command pattern [Gang of Four].

所以我可以在表模块中做到这一点,我可以为每个演示请求提供方法,同时我可以在事务脚本模式中使用 DataSet 或 RecordSet。那么我怎么知道我应该在我的领域逻辑中使用哪种模式呢?

最佳答案

我认为基本区别在于所涵盖的业务逻辑范围。在表模块中,您仅限于单个表或 View ,但事务脚本不是。

例如,假设您有一个跟踪财务交易的表,并且您的业务逻辑规定每次更新财务交易时,与交易相关的预算也会在单独的表中更新。

在表模块的情况下,您需要两个过程,一个用于财务交易,一个用于预算。

对于事务脚本,您只需要一个更新两个表的脚本。

关于c# - 表模块和事务脚本之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8885447/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com