“Layers”和“Tiers”的区别是什么?
当前回答
我发现一个定义说,层是逻辑分离,层是物理分离。
其他回答
IBM的三层体系结构文章有一个章节专门讨论这个主题:
In discussions of three-tier architecture, layer is often used interchangeably – and mistakenly – for tier, as in 'presentation layer' or 'business logic layer.' They aren't the same. A 'layer' refers to a functional division of the software, but a 'tier' refers to a functional division of the software that runs on infrastructure separate from the other divisions. The Contacts app on your phone, for example, is a three-layer application, but a single-tier application, because all three layers run on your phone. The difference is important, because layers can't offer the same benefits as tiers.
层指的是代码的逻辑分离。逻辑层帮助您更好地组织代码。例如,应用程序可以具有以下层。
表示层或UI层 业务层或业务逻辑层 数据访问层或数据层
上述三个层驻留在它们自己的项目中,可能是3个项目,甚至更多。当我们编译这些项目时,我们得到了相应的层DLL。现在我们有3个dll了。
根据我们部署应用程序的方式,我们可能有1到3层。因为我们现在有3个DLL,如果我们将所有DLL部署在同一台机器上,那么我们只有1个物理层,但有3个逻辑层。
如果我们选择将每个DLL部署在单独的机器上,那么我们就有3层和3层。
层是逻辑上的分离,层是物理上的分离。我们也可以说层是层的物理部署。
Logical layers are merely a way of organizing your code. Typical layers include Presentation, Business and Data – the same as the traditional 3-tier model. But when we’re talking about layers, we’re only talking about logical organization of code. In no way is it implied that these layers might run on different computers or in different processes on a single computer or even in a single process on a single computer. All we are doing is discussing a way of organizing a code into a set of layers defined by specific function. Physical tiers however, are only about where the code runs. Specifically, tiers are places where layers are deployed and where layers run. In other words, tiers are the physical deployment of layers.
来源:Rockford Lhotka,所有应用程序都应该是n层吗?
我发现一个定义说,层是逻辑分离,层是物理分离。
从技术上讲,Tier可以是代码运行所需的一种最小环境。
例如,假设一个3层应用程序可以运行
3 physical machines with no OS . 1 physical machine with 3 virtual machines with no OS. (That was a 3-(hardware)tier app) 1 physical machine with 3 virtual machines with 3 different/same OSes (That was a 3-(OS)tier app) 1 physical machine with 1 virtual machine with 1 OS but 3 AppServers (That was a 3-(AppServer)tier app) 1 physical machine with 1 virtual machine with 1 OS with 1 AppServer but 3 DBMS (That was a 3-(DBMS)tier app) 1 physical machine with 1 virtual machine with 1 OS with 1 AppServers and 1 DBMS but 3 Excel workbooks. (That was a 3-(AppServer)tier app)
Excel工作簿是运行VBA代码所需的最低环境。
这3个工作簿可以放在一台物理计算机上,也可以放在多个物理计算机上。
我注意到,在实践中,人们在应用描述上下文中说“层”时,指的是“操作系统层”。
也就是说,如果一个应用运行在3个不同的操作系统上,那么它就是一个3层应用。
所以从学究角度来说,描述应用程序的正确方法是
“1至3层能力,运行在2层”应用程序。
:)
层只是应用程序中职责功能分离的代码类型(例如,表示,数据,安全等)。