3 层架构与 2 层架构 [英] 3 Tier Architecture vs 2 Tier Architecture

查看:31
本文介绍了3 层架构与 2 层架构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们真正需要三层架构的例子有哪些?大多数使用 3 层架构的应用程序可以使用 2 层架构完成吗?

What are the examples where we really need 3 Tier Architecture ? Can Most of the Application which are using 3 Tier Architecture be done using 2 Tier Architecture ?

注意:我试图看到 3 层架构的价值,我觉得现在有 3 层的大多数应用程序都可以在 2 层中完成,所以我正在寻找示例我们绝对需要 3 层,这种需求也不例外.

Note: I am trying to see value of 3 Tier Architecture, I feel most of the application that there are 3 tier right now can be done in 2 tier and so I am looking for examples where we absolutely need 3 tier and there is no exception to that need.

推荐答案

我猜你的意思是分层(分离的逻辑单位)而不是分层(分离/部署的物理单位).分层系统的一个例子是一个网络服务器(第一层),它提供网页(另一层),它从第三层数据库中提取数据).

I'm guessing that you mean layered (logical units of separation) rather than tiered (physical units of separation/deployment). An example of a tiered system would be a web server (1 tier) delivering web pages (another tier) which draws on data from a database the 3rd tier).

分层架构的通常目标是分离职责.这有两个主要好处(除其他外).

The usual aim of a layered architecture is to separate out responsibilities. This has two key benefits (amongst others).

首先,您的设计将更加清晰,因为职责不会混淆,因此代码将更易于阅读、理解和维护.

First of all your design will be clearer as responsibilities won't be muddied and thus the code will be easier to read, understand and maintain.

其次,您可能会减少重复 - 例如,在 Web 应用程序中,如果您的页面还处理业务逻辑(或可怕的数据访问)以及显示页面,那么您可以相当确定多个页面将尝试做相同或相似的事情.

Secondly the chances are you'll be reducing duplication - for example in a web app if your pages are also handling business logic (or horror of horrors data access) as well as displaying the pages then you can be fairly sure that multiple pages will be trying to do the same or similar things.

您不需要需要构建(例如,分层,尽管有其他方法)任何软件,但对于除微不足道的事情之外的任何事情,如果您不这样做,结果将是无法维护的混乱

You don't need to architect (e.g. into layers, although there are other ways) any piece of software but for anything apart from trivial things the result will be an unmaintainable mess if you don't.

这篇关于3 层架构与 2 层架构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆