【常见架构01】WEB经典三层架构与MVC三层架构中两个 “层” 是一样的吗?

4 篇文章 0 订阅

文章持续更新中…

最近转到新架构项目的同事关于cola 4.0有一些疑问,交流过程中发现关于常见的架构有一些误解。于是为下次内部知识分享会我准备了PPT,这里把部分内容展示出来。

本文为本人制作的PPT中截取的一部分,有大量引用

WEB 经典三层架构与MVC三层架构


“层”的概念区分

很多开发人员混淆了WEB的“层”和MVC的“层”,在IBM Cloud Education有进行区分:

Three-Tier Architecture

Tier vs. layer
   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.

清楚地指明了,Tier与Layer属于不同维度的概念。


这里我绘制了这张图,展示了这两个概念之间的关系:

在这里插入图片描述

WEB 三层架构

      先简单看一下wikipedia中的多层架构描述(无关WEB)

   In software engineering, multitier architecture (often referred to as n-tier architecture) is a client–server architecture in which presentation, application processing and data management functions are physically separated. The most widespread use of multitier architecture is the three-tier architecture.

   N-tier application architecture provides a model by which developers can create flexible and reusable applications. By segregating an application into tiers, developers acquire the option of modifying or adding a specific tier, instead of reworking the entire application. A three-tier architecture is typically composed of a presentation tier, a logic tier, and a data tier.

      显然,三层架构属于多层架构的一种,架构层次的划分可以认为是与语言无关的(当然具体设计架构时,需要考虑到语言特性)。这个描述的只是三层架构。

      wikipedia的图片准确地描述了此种关系:

Three-tier architecture

      关于web应用开发,wikipedia也给了进一步的说明:

   In the web development field, three-tier is often used to refer to websites, commonly electronic commerce websites, which are built using three tiers:

   A front-end web server serving static content, and potentially some cached dynamic content. In web-based application, front end is the content rendered by the browser. The content may be static or generated dynamically.


   A middle dynamic content processing and generation level application server (e.g., Symfony, Spring, ASP.NET, Django, Rails, Node.js).


   A back-end database or data store, comprising both data sets and the database management system software that manages and provides access to the data.

这web三层架构显然符合上图的层次划分思想。

MVC架构

      先简单看一下wikipedia中的关于MVC描述(无关WEB)

   Model–view–controller (MVC) is a software architectural pattern commonly used for developing user interfaces that divide the related program logic into three interconnected elements. This is done to separate internal representations of information from the ways information is presented to and accepted from the user.

      再来看看mozilla在其MDN上给的描述及图例

   MVC (Model-View-Controller) is a pattern in software design commonly used to implement user interfaces, data, and controlling logic. It emphasizes a separation between the software’s business logic and display. This “separation of concerns” provides for a better division of labor and improved maintenance. Some other design patterns are based on MVC, such as MVVM (Model-View-Viewmodel), MVP (Model-View-Presenter), and MVW (Model-View-Whatever).
   The three parts of the MVC software-design pattern can be described as follows:

         Model: Manages data and business logic.


         View: Handles layout and display.


         Controller: Routes commands to the model and view parts.

MVC-01

是不是异常清晰明了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值