Skip to content

通过知识获得解放,通过技术获得自由

Menu
  • 专题目录
  • 液压相关
    • 液压技术
    • 液压相邻技术
    • 液压应用
  • 计算机相关
    • 计算机和软件
    • 网络和网站技术
  • 哲学
  • 关于本站
Menu

软件的模块独立[0]

Posted on 2023年11月14日 by

模块的独立程度可以由两个定性标准度量,这两个标准分别称为内聚和耦合。

  • 耦合

耦合是对一个软件结构内不同模块之间互连程度的度量。

可分为:数据耦合、控制耦合、特征耦合、公共环境耦合和内容耦合。

1)数据耦合

两个模块彼此间通过参数交换信息,而且交换的信息仅仅是数据。

2)控制耦合

传递的信息中有控制信息(尽管有时这种控制信息以数据的形式出现)

3)特征耦合

当把整个数据结构作为参数传递而被调用的模块只需要使用其中一部分数据元素时,就出现了特征耦合。

4)公共环境

当两个或多个模块通过一个公共数据环境相互作用时,它们之间的耦合称为公共环境(可以是全程变量、共享的通信区、文件等)耦合。

5)内容耦合

一个模块访问另一个模块的内部数据, 一个模块不通过正常入口而转到另一个模块的内部,两个模块有一部分程序代码重叠,一个模块有多个入口。

尽量使用数据耦合,少用控制耦合和特征耦合,限制公共环境耦合的范围,完全不用内容耦合。

  • 内聚

内聚衡量一个模块内部各个元素彼此结合的紧密程度。

理想内聚的模块只做一件事情,模块内的高内聚往往意味着模块间的松耦合。

可分为:低内聚、中内聚和高内聚

1)低内聚

一个模块完成一组任务,这些任务彼此间即使有关系,关系也是很松散的,就叫做偶然内聚。一个模块完成的任务在逻辑上属于相同或相似的一类,则称为逻辑内聚。一个模块包含的任务必须在同一段时间内执行,就叫时间内聚。

2)中内聚

一个模块内的处理元素是相关的,而且必须以特定次序执行,则称为过程内聚。模块中所有元素都使用同一个输入数据和(或)产生同一个输出数据,则称为通信内聚。

3)高内聚

一个模块内的处理元素和同一个功能密切相关,而且这些处理必须顺序执行(通常一个处理元素的输出数据作为下一个处理元素的输入数据),则称为顺序内聚。模块内所有处理元素属于一个整体,完成一个单一的功能,则称为功能内聚。

功能内聚是最高程度的内聚。

参考资料:

  1. 《软件工程导论》-张海藩(第六版)

欢迎回来

希望本站对你有所帮助!

如有疑问请联系info@fanlog.org
2023 年 11 月
一二三四五六日
 12345
6789101112
13141516171819
20212223242526
27282930 
« 6 月    

AI辅助 (17)

© 2025 | Powered by Superbs Personal Blog theme
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent.
Cookie SettingsAccept All
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT