问题 单项选择题

软件设计中划分程序模块通常遵循的原则是要使各模块间的耦合性尽可能 (58) 。三种可能的模块耦合是:

(59) 。例如,一个模块直接引用另一模块中的数据。

(60) 。例如,一个模块把开关量作为参数传送给另一模块。

(61) 。例如,一个模块把一个数值量作为参数传送给另一模块。其中 (62) 的耦合性最强。

(62)是()

A.公共耦合

B.数据耦合

C.逻辑耦合

D.外部耦合

E.内容耦合

F.控制耦合

答案

参考答案:E

解析:

耦合度是对一个软件结构内不同模块之间互连程度的度量。耦合强弱取决于模块间接口的复杂程度、进入访问一个模块的点及通过接口的数据。在软件设计中应该追求尽可能松散的耦合系统,在这样的系统中可以研究、测试或修改、维护任何一个模块,而不需要对系统的其他模块有很多了解或影响其他模块的实现。此外,当某处发生错误时,低耦合度系统的错误传播的范围相对小些。

耦合取决于各个模块间接口的复杂程度、调用模块的方式,以及哪些信息通过接口。耦合的强度依赖于以下几个因素:

(1)一个模块对另一个模块的调用:

(2)一个模块向另一个模块传递的数据量;

(3)一个模块施加到另一个模块的控制的多少:

(4)模块之间接口的复杂程度。

一般模块之间可能的连接方式有7种,它们构成耦合性的7种类型,如图9-5所示。

(1)非直接耦合(Nondirective Coupling):如果两个模块之间没有直接关系,它们之间的联系完全是通过主模块的控制和调用来实现的,这就是非直接耦合。这种耦合的模块独立性最强。

(2)数据耦合(Data Coupling):如果一个模块访问另一个模块时,彼此之间是通过简单数据参数(不是控制参数、公共数据结构或外部变量)来交换输入、输出信息的,则称这种耦合为数据耦合。

(3)标记耦合(Stamp Coupling):如果一组模块通过参数表传递记录信息,这称为标记耦合。这个记录是某一数据结构的子结构,而不是简单变量。

(4)控制耦合(Control Coupling):如果一个模块通过传送开关、标志、名字等控制信息,明显地控制选择另一模块的功能,这种耦合称为控制耦合。

(5)外部耦合(External Coupling):一组模块都访问同一全局简单变量而不是同一全局数据结构,而且不是通过参数表传递该全局变量的信息,则称之为外部耦合。

(6)公共耦合(Common Coupling):若一组模块都访问同一个公共数据环境,则它们之间的耦合就称为公共耦合。公共的数据环境可以是全局数据结构、共享的通信区、内存的公共覆盖区等。公共耦合的复杂程度随耦合模块的个数增加而显著增加。若只是两模块间有公共数据环境,则公共耦合有两种情况,分别是松散公共耦合和紧密公共耦合。

(7)内容耦合(Content Coupling):如果发生下列情形,两个模块之间就发生了内容耦合,即一个模块直接访问另一个模块的内部数据;一个模块不通过正常入口转到另一模块内部;两个模块有一部分程序代码重叠(只可能出现在汇编语言中);一个模块有多个入口。

阅读理解

When you are watching TV, you will notice that more and more famous stars make the ads on TV. Many people believe them because they are famous. But have you ever thought if the ads are real or not?

In the past few years, lots of stars have been on TV or newspapers as spokesmen(代言人) of some products(产品), such as Sanlu Milk and Haojixing Study Machine. People spent much money on these products, but at last, many of them were not like what the stars said. More and more people are very angry with the famous actors for making the ads after the accident of Sanlu Children Milk.

What are the public’s ideas about the famous people making ads on TV? Do you agree that the famous people should take responsibility (负责任) if the products have any problems? A research shows that about 36% think it wasn’t the famous stars’fault(过错),but they all think famous stars should give out the money they got from the ads or the charity(慈善机构).More than34%think the famous stars must take responsibility.They are dishonest and lose themselves in the public.

So we should be more careful when we buy things advertised by the stars. We must find what these things are really like instead of only listening to what the stars say.

小题1:Many people believe the ads because they’re made by famous people.

小题2:In fact, some products were not like what the stars said.

小题3:About 36% think famous stars should give out the money they got from the ads to the charity.

小题4:All the famous actors are not honest and lose themselves in the public

小题5:When we buy things, we should only listen to what the stars say.

单项选择题