.NET 中 3 层和 n 层架构之间的主要区别?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11542960/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 16:32:41  来源:igfitidea点击:

Main Difference Between 3-tier & n-tier Architecture in .NET?

.netn-tier-architecture3-tier

提问by immayankmodi

I have searched Google to find the main difference between 3-tier and n-tier architecture in .net but I have failed to find it out. Several sites said both are the same in nature and some of the sites said there are differences between them.

我在谷歌上搜索过 .net 中 3 层和 n 层架构之间的主要区别,但我没有找到。一些网站表示两者在性质上是相同的,一些网站表示它们之间存在差异。

I want to know the major differences, and which one is better in performance optimization?

我想知道主要的区别,在性能优化上哪个更好?

回答by Nikola Mitev

3-tier architecture is general architecture in software development and it consists of

三层架构是软件开发中的通用架构,它包括

  • Presentation layer (client browser)

  • Application or Business logic layer

  • Data Layer

  • 表示层(客户端浏览器)

  • 应用程序或业务逻辑层

  • 数据层

n-tier architecture in .Net

.Net 中的 n 层架构

enter image description here

在此处输入图片说明

The main difference is that n-tier arch got 2 extra layers. Example on data layers one part of developers are SQL developers whose work on DB server (making DB structure, writing Stored procedures and so forth), and .Net developers whose work on consuming that stored procedures and making abstraction ( implementing repository pattern)...

主要区别在于 n-tier arch 多了 2 层。数据层的例子 一部分开发人员是 SQL 开发人员,他们在 DB 服务器上工作(制作 DB 结构,编写存储过程等),以及 .Net 开发人员,他们的工作是使用该存储过程并进行抽象(实现存储库模式)。 .

Hope this help you.

希望这对你有帮助。

回答by CodeRedick

I know this question is old, but the really simple and ultimately correct answer is:

我知道这个问题很老,但真正简单且最终正确的答案是:

3-tier isN-tier where N=3.

3 层N 层,其中 N=3。

回答by Nuwan Wimalasooriya

msdn link

msdn 链接

An N-Tier application is an application where you have 3 or more physical tiers. I mean with that things like, “Presentation/Client Tier”, “Application/Business Server Tier” and “Data Tier” (a database server in most of the cases) and nowadays we use web services (or even better, WCF Services) to communicate between presentation tier and the application server tier. Here you see a simple & typical picture about N-Tier architecture:

N 层应用程序是具有 3 个或更多物理层的应用程序。我的意思是诸如“演示/客户端层”、“应用程序/业务服务器层”和“数据层”(大多数情况下是数据库服务器)之类的东西,现在我们使用 Web 服务(甚至更好的 WCF 服务)在表示层和应用服务器层之间进行通信。在这里,您可以看到有关 N 层架构的简单而典型的图片:

A different matter is that we'd probably design our application as an N-Layer application, I mean, with several logic layers where we implement different logic tasks. For example we could have the DAL layer (Data Access Layer), BLL Layer (Business Logic Layer), BFLL Layer (Busines Fa?ade Logic Layer), WCF Service Layer and several Presentation layers depending of the pattern we use, like MVC (Model-View-Controller), MVP (Model-View-Presenter), etc.. Also, within the N-Layer architecture, you can guess that Entity Framework fits as the DAL Layer (Data Access Classes) as well as using EF entities as our disconnected entities to pass thru all the layers, all right?

另一件事是,我们可能会将我们的应用程序设计为 N 层应用程序,我的意思是,具有多个逻辑层,我们在其中实现不同的逻辑任务。例如,根据我们使用的模式,我们可以拥有 DAL 层(数据访问层)、BLL 层(业务逻辑层)、BFLL 层(业务外观逻辑层)、WCF 服务层和几个表示层,例如 MVC( Model-View-Controller)、MVP(Model-View-Presenter)等。此外,在 N 层架构中,您可以猜测实体框架适合作为 DAL 层(数据访问类)以及使用 EF 实体作为我们断开连接的实体通过所有层,好吗?

BTW, not all N-Layer apps should be N-Tier apps, but all N-Tier Apps must internally be designed as N-Layer. I mean, there are many cases where the less you physically split your model, the better for performance (more tiers is good for scalability but not for pure performance, due to latencies). Remember, N-Layer is about logic layers.

顺便说一句,并非所有 N-Layer 应用程序都应该是 N-Tier 应用程序,但是所有 N-Tier 应用程序必须在内部设计为 N-Layer。我的意思是,在很多情况下,您对模型进行物理拆分的次数越少,性能就越好(由于延迟,更多的层有利于可扩展性,但不利于纯性能)。请记住,N 层是关于逻辑层的。

OK!, so if we get back to the N-Tier architecture (physical tiers), like I said, we need remote mechanisms to communicate the client tier with the application server tier (for instance, WCF Services) and therefore when we query the database from the app server tier, to obtain data (like an Order), we keep it as an EF entity, then we disconnect it from the EF context (detach), WCF serializes it and sends that disconnected entity to the presentation tier (client apps & machines).

好的!所以如果我们回到 N 层架构(物理层),就像我说的,我们需要远程机制来将客户端层与应用程序服务器层(例如,WCF 服务)进行通信,因此当我们查询从应用程序服务器层获取数据库,为了获取数据(如订单),我们将其保留为 EF 实体,然后将其与 EF 上下文断开连接(分离),WCF 对其进行序列化并将该断开连接的实体发送到表示层(客户端应用程序和机器)。

回答by Baig

The difference between N -Tierand 3 Tieris as follows.

之间的差N -Tier3 Tier如下。

In 3 TierApplication there are three tiers like Presentation Layer , Application Layer and Data layer. Here the application layer contains business logic as well .

3 Tier应用程序中有三层,如表示层、应用程序层和数据层。这里的应用层也包含业务逻辑。

On the other hand in N TierApplication layer is divided into 2 i.e. Application Layer and Business Logic layer. The Application Layer you can add up to Nnumber depending on the data coming from presentation layer (Different OS , Different platforms etc).

另一方面在N Tier应用层分为2个即应用层和业务逻辑层。N根据来自表示层(不同操作系统、不同平台等)的数据,您可以将应用层加起来。