Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Design patterns 三层体系结构中的模型在哪里_Design Patterns_N Tier Architecture_Three Tier - Fatal编程技术网

Design patterns 三层体系结构中的模型在哪里

Design patterns 三层体系结构中的模型在哪里,design-patterns,n-tier-architecture,three-tier,Design Patterns,N Tier Architecture,Three Tier,我正在研究三层体系结构,我有一个问题,我似乎真的找不到解决方案。尽管网上有很多关于三层体系结构的文章,但没有一篇提到数据模型。除了在MVC的上下文中 我有以下体系结构: 所以我们在这里看到的是,每一层都使用数据模型。假设我有一个新用户订阅: UI : * Get the data from the http request * Build a `UserModel()` with this data * Pass this `UserModel` to the applic

我正在研究三层体系结构,我有一个问题,我似乎真的找不到解决方案。尽管网上有很多关于三层体系结构的文章,但没有一篇提到数据模型。除了在MVC的上下文中

我有以下体系结构:

所以我们在这里看到的是,每一层都使用数据模型。假设我有一个新用户订阅:

UI : * Get the data from the http request
     * Build a `UserModel()` with this data
     * Pass this `UserModel` to the application layer
APP: * Pass the `UserModel` to the DB layer
DB : * Format the `UserModel` to SQL and write to DB.
因此,实际上所有层都有这个数据模型的概念。我想知道这是否就是重点

相反,假设我想解决这个问题,我可以让UI将“原始”数据(即字符串格式的用户值)传递给应用层。应用程序层将是唯一具有用户模型概念的层。因此,它将使用此数据创建
UserModel
。然后我将如何继续将其传递到数据库层,而数据库层没有模型的概念,这是一个棘手的问题。所以我不知道该怎么做


简言之,我被卡住了。非常感谢您的帮助。

在所有层中使用数据模型对象确实是关键所在。
在GUI中创建新数据时,将在表示层中创建数据模型对象,并将其传递到数据/持久性层。查询数据时,数据模型对象在持久层中实例化并传递到表示层。

除非引入DTO,否则该模型横切所有层。它们基本上是整个项目共享层的一部分