当前位置:网站首页>What is high cohesion and low coupling?
What is high cohesion and low coupling?
2022-07-07 11:32:00 【Full stack programmer webmaster】
cause : Module independence means that each module only completes the independent sub functions required by the system , And it has the least connection with other modules and the interface is simple , Two qualitative measures ―― Coupling and cohesion . Coupling is also called inter block connection . A measure of the degree to which modules in a software system structure are closely related to each other . The closer the connection between modules , The more coupled it is , The less independent the module is . The coupling between modules depends on the complexity of the interface between modules 、 The way of calling and the information transmitted .
Coupling classification ( low ―― high ): No direct coupling ; Data coupling ; Tag coupling ; Control coupling ; Public coupling ; Content coupling ;
1 No direct coupling :
2 Data coupling : It refers to the calling relationship between two modules , What is passed is a simple data value , Equivalent to the value passing of high-level language ;
3 Tag coupling : It refers to the data structure passed between two modules , For example, array names in high-level languages 、 Record name 、 File names and so on are marked , In fact, it is the address of the data structure ;
4 Control coupling : When one module calls another , What is passed is the control variable ( Like a switch 、 Signs, etc ), The tuned module selectively performs a function within the block through the value of the control variable ;
5 Public coupling : Refers to the coupling between modules that interact through a common data environment . Complex programs with common coupling increase with the number of coupling modules .
6 Content coupling : This is the highest level of coupling , And the worst coupling . When one module directly uses the internal data of another module , Or through the abnormal entrance into another module .
Cohesion is also called intra block connection . A measure of the functional strength of a module , That is, a measure of the closeness of the various elements within a module . If every element in a module ( Between names 、 Between segments ) The more connected , The more cohesive it is . Cohesive bandits ( low ―― high ): To gather by chance ; Logical cohesion ; Time converges ; Communication cohesion ; Order cohesion ; Functional cohesion ;
1 To gather by chance : It means that there is no relationship between the processing elements in a module .
2 Logical cohesion : It refers to the execution of several logically similar functions in the module , Through the parameters to determine which function the module completes .
3 Time converges : The module formed by combining the actions that need to be executed at the same time is a time cohesion module .
4 Communication cohesion : All processing elements in the module operate on the same data structure ( Sometimes it's called information cohesion ), Or each process uses the same input data or produces the same output data .
5 Order cohesion : It refers to that each processing element in a module is closely related to the same function and must be executed in sequence , The output of the former function element is the input of the next function element .
6 Functional cohesion : This is the strongest cohesion , It means that all elements in the module complete a function together , Be short of one cannot . Coupling with other modules is the weakest .
Coupling and cohesion are two qualitative criteria of module independence , When dividing the software system into modules , Strive for high cohesion and low coupling , Improve the independence of modules , Lay the foundation for designing high quality software structure .
There's an example that's easy to understand : A program has 50 A function , This program works very well ; But once you modify one of these functions , other 49 All functions need to be modified , This is the consequence of high coupling . Once you understand it , When you write a profile design, the design class or module will naturally take “ High cohesion , Low coupling ”.
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/113823.html Link to the original text :https://javaforall.cn
边栏推荐
- electron添加SQLite数据库
- Eth trunk link switching delay is too high
- How to write test cases for test coupons?
- R语言使用quantile函数计算评分值的分位数(20%、40%、60%、80%)、使用逻辑操作符将对应的分位区间(quantile)编码为分类值生成新的字段、strsplit函数将学生的名和姓拆分
- Verilog 实现数码管显视驱动【附源码】
- Case study of Jinshan API translation function based on retrofit framework
- Reasons for the failure of web side automation test
- 聊聊SOC启动(十一) 内核初始化
- The running kubernetes cluster wants to adjust the network segment address of pod
- Antd select selector drop-down box follows the scroll bar to scroll through the solution
猜你喜欢
在我有限的软件测试经历里,一段专职的自动化测试经验总结
数据库同步工具 DBSync 新增对MongoDB、ES的支持
Verilog realizes nixie tube display driver [with source code]
测试开发基础,教你做一个完整功能的Web平台之环境准备
Talk about SOC startup (IX) adding a new board to uboot
【系统设计】指标监控和告警系统
Socket socket programming
正在運行的Kubernetes集群想要調整Pod的網段地址
关于jmeter中编写shell脚本json的应用
RationalDMIS2022阵列工件测量
随机推荐
Talk about SOC startup (VII) uboot startup process III
Using ENSP to do MPLS pseudo wire test
一度辍学的数学差生,获得今年菲尔兹奖
Poor math students who once dropped out of school won the fields award this year
Enclosed please find. Net Maui's latest learning resources
Common SQL statement collation: MySQL
QT | multiple windows share a prompt box class
R语言使用magick包的image_mosaic函数和image_flatten函数把多张图片堆叠在一起形成堆叠组合图像(Stack layers on top of each other)
博客搬家到知乎
Une fois que l'uniapp a sauté de la page dans onlaunch, cliquez sur Event Failure resolution
CentOS系统下Redis安装和自启动配置的步骤
Verilog design responder [with source code]
正在运行的Kubernetes集群想要调整Pod的网段地址
互联网协议
TDengine 社区问题双周精选 | 第二期
Hash / (understanding, implementation and application)
Verilog 实现数码管显视驱动【附源码】
The database synchronization tool dbsync adds support for mongodb and es
sink 消费 到 MySQL, 数据库表里面已经设置了 自增主键, flink 里面,如何 操作?
竟然有一半的人不知道 for 与 foreach 的区别???