发布于 2026-01-06 0 阅读
0

Web架构模式:分层模式

Web架构模式:分层模式

欢迎!在本系列文章中,我们将逐一探讨不同的架构模式。

架构模式是解决软件应用程序架构问题的常用方法。

它们是涉及大规模组件、系统全局特性和机制的高层次战略。

大型复杂软件需要经历不同层次的解构。
在宏观层面,架构模式是工具;在微观层面,设计模式是工具;而在实现层面,编程范式是工具。

第一种架构模式:

  1. 层叠图案

    • The most common architecture pattern is the layered 
      architecture pattern, otherwise known as the n-tier 
      architecture pattern
    
    • Components within the layered architecture pattern are 
      organized into horizontal layers, each layer performing 
      a specific role within the application 
    
    • The layered architecture pattern does not specify the 
      number and types of layers that must exist in the 
      pattern.
    

大多数分层架构由四个标准层组成:表示层、业务层、持久层和数据库层。 

隔离层概念还意味着每一层都与其他层相互独立,因此对架构中其他层的内部运作知之甚少或一无所知。

替代文字

1.1 不同层:

表示层:  包含所有负责向最终用户呈现用户界面或将响应发送回客户端的类。 

业务层: 代表底层领域,主要由领域实体构成,在某些情况下也包含服务。业务规则,例如不变量和算法,都应该保留在这一层。

持久层和数据库层:包含所有负责执行技术工作的类,例如将数据持久化到数据库中,如 DAO、存储库。

用法

• General desktop applications.
• E commerce web applications.

分层架构的核心在于组织代码以实现良好的关注点分离,仅此而已。

资源

https://dzone.com/articles/layered-architecture-is-good
https://www.oreilly.com/library/view/software-architecture-patterns/9781491971437/ch01.html
https://stackoverflow.com/questions/4243187/whats-the-difference-between-design-patterns-and-architectural-patterns

文章来源:https://dev.to/readthroughmyglasses/web-architecture-patterns-1-1jfa