模块化、组件化、服务化、微服务化:Overview

在网上搜这几个词的区别时,你会发现大家都是各说各的,感觉每一个人说的都很有道理,但大家的说法却不尽相同甚至互相矛盾,给我看得是云里雾里的。。。这里,我挑选我最信服的说法,做一个整理与归纳,主要的结论采选自文末的三篇文献,本文是将此三篇文献做了一个汇总与综述,整理结论如下:


1)模块化(Modular Programming)

维基百科定义如下:

  • Modular programming is a software design technique that emphasizes separating the functionality of a program into independent, interchangeable modules, such that each contains everything necessary to execute only one aspect of the desired functionality.
  • With modular programming, concerns are separated such that modules perform logically discrete functions, interacting through well-defined interfaces.

模块化最初的思想诞生于1972年,由Parnas 等⼈提出(information hiding and separation of concerns),简单来讲是每个模块只给出功能接口,而隐藏功能实现程序的细节,只有该模块自己知道其中细节,对于要修改部分的接口则可以公开。随后,围绕 “高内聚、低耦合” 原则,依赖静态、动态数据分析等⽅法,衍⽣出了⼀系列单体系统模块化技术和⼯具研究成果。模块化的思想广泛应用于单体架构中,旨在实现隔离/封装 (高内聚) 的目的。模块之间有依赖的关系,可通过路由器实现模块间的耦合[1]。


2)组件化(Component-based software engineering)

维基百科定义如下:

  • Component-based software engineering (CBSE), also called component-based development (CBD), is a branch of software engineering that emphasizes the separation of concerns with respect to the wide-ranging functionality available throughout a given software system. It is a reuse-based approach to defining, implementing and composing loosely coupled independent components into systems. This practice aims to bring about an equally wide-ranging degree of benefits in both the short-term and the long-term for the software itself and for organizations that sponsor such software.

组件化就是基于可重用的目的,将一个大的软件系统按照分离关注点的形式,拆分成多个独立的组件,主要目的就是复用、解耦(减少耦合),组件之间低依赖,比较独立[1]。


模块化与组件化之间的区别 [2]:

模块化与组件化的区别并不大,其核心思想都是为了将一个完整的服务系统解耦,以实现分而治之。只是一个拆分后叫模块,另一个拆分后叫组件。拆分后的区别并不显著,若真要提出两者之间的区别,可总结为以下两点:

  1. 目的不同: 模块化的目的更偏向于隔离、封装、解耦、高内聚;而组件化的目的则更偏向于复用,可插拨到不同的平台。做个类比:组件相当于库,把一些能在项目里或者不同类型项目中可复用的代码进行工具性的封装。而模块相应于业务逻辑模块,把同一类型项目里的功能逻辑进行进行需求性的封装。
  2. 解耦方向不同: 组件化的解耦思想是纵向分层(位于架构底层,被其他层所依赖),而模块化的解耦思想则为横向分块(位于架构业务框架层)。

3)服务化

  • 服务化是一种粗粒度、松耦合的以服务为中心的架构,服务之间通过定义明确的协议和接口进行通信[3]。

模块化与微服务化间的区别 [3]:

  • 模块化拆分粒度程序⽚段之间不完全独⽴,需要依赖进程间通信,不能很好地⽀持独⽴开发、部署和独⽴弹性伸缩。

另外,提到服务化,不得不提一种架构:面向服务的架构(Service-Oriented Architecture,SOA),维基百科定义如下:

  • In software engineering, service-oriented architecture (SOA) is an architectural style that supports service orientation.By consequence, it is as well applied in the field of software design where services are provided to the other components by application components, through a communication protocol over a network. A service is a discrete unit of functionality that can be accessed remotely and acted upon and updated independently, such as retrieving a credit card statement online. SOA is also intended to be independent of vendors, products and technologies.
  • Service orientation is a way of thinking in terms of services and service-based development and the outcomes of services.

服务是一个独立的功能单元,可以远程访问并独立执行和更新。不同的服务可以作为服务网格结合使用,以提供大型软件应用程序的功能。需要注意的是:SOA只是一种体系、一种思想,而不是某种具体的软件产品。


4)微服务化

  • 微服务化是建⽴在业务系统组件化和服务化的基础上,识别独⽴的、更细粒度的业务流程和数据库进⾏拆分,不单纯对程序或服务特征进⾏提取[3]。我们可以将微服务架构看成更细粒度的面向服务架构。

其中,Martin老头给的微服务定义如下:

  • The microservice architectural style is an approach to developing a single application as a suite of small services, each running in its own process and communicating with lightweight mechanisms, often an HTTP resource API. These services are built around business capabilities and independently deployable by fully automated deployment machinery. There is a bare minimum of centralized management of these services , which may be written in different programming languages and use different data storage technologies.


参考网址:

[1] 组件化、模块化、集中式、分布式、服务化、面向服务的架构、微服务架构

[2] 分析组件化与模块化之间的区别

[3] 李杉杉. 面向微服务架构的单体系统拆分技术研究[D].南京大学,2021

  • 0
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值