functional cohesion

Computer Science An Overview _J. Glenn Brookshear _11th Edition

A weak form of cohesion is known as logical cohesion. This is the cohesion within a module induced by the fact that its internal elements perform activities logically similar in nature. For example, consider a module that performs all of a system’s communication with the outside world. The “glue” that holds such a module together is that all the activities within the module deal with communication. However, the topics of the communication can vary greatly. Some may deal with obtaining data, whereas others deal with reporting results.

A stronger form of cohesion is known as functional cohesion, which means that all the parts of the module are focused on the performance of a single activity. In an imperative design, functional cohesion can often be increased by isolating subtasks in other modules and then using these modules as abstract tools. This is demonstrated in our tennis simulation example (see again Figure 7.3) where the module ControlGame uses the other modules as abstract tools so that it can concentrate on overseeing the game rather than being distracted by the details of serving, returning, and maintaining the score.

In object-oriented designs, entire objects are usually only logically cohesive because the methods within an object often perform loosely related activities— the only common bond being that they are activities performed by the same object. For example, in our tennis simulation example, each player object contains methods for serving as well as returning the ball, which are significantly different activities. Such an object would therefore be only a logically cohesive module. However, software designers should strive to make each individual method within an object functionally cohesive. That is, even though the object in its entirety is only logically cohesive, each method within an object should perform only one functionally cohesive task (Figure 7.7).

时间: 2024-07-30 07:56:27

functional cohesion的相关文章

内聚性

?有很多类型的内聚性. 最常用到的两个是通信性内聚( communicational cohesion) 和 功能性内聚( functional cohesion).在模块中的部件操作相同的数据时,可以得到通信性内聚. 把 它们分到一组很有意义,因为它们之间存在很强的关联性. 在模块中的部件协同工作以完成定义好的任务时,可以得到功能性内聚. 功能性内聚被认为是最佳的内聚类型.?????????????????????????????????????????????????????????????

js函数设计原则

一般认为函数指具有返回值的子程序,过程指没有返回值的子程序.C++中把所有子程序成为函数,其实那些返回值为void的 函数在语义上也是过程.函数与过程的区别更多是语义上的区别,而不是语法的区别. 语言纯化论者认为一个函数应该只有一个返回值,这和数学函数一样.即函数只接受输入(参数),通过参数运算返回结果. 除此之外的效果被称为函数的副作用,比如修改全局变量. function sum1(x, y) { return x+y }function sum2(x, y) { alert(x+y) }s

面向对象设计之高内聚、低耦合

内聚 内聚的含义:内聚指一个模块内部元素彼此结合的紧密程度 在面向对象领域,谈到"内聚"的时候,模块的概念远远不止我们通常所理解的"系统内的某个模块"这个范围,而是可大可小,大到一个子系统,小到一个函数,你都可以理解为内聚 里所说的 "模块".所以可以用"内聚"来判断一个函数设计是否合理,一个类设计是否合理,一个接口设计是否合理, 一个包设计是否合理,一个模块/子系统设计是否合理. 其次:"元素"究竟是什么

《Code Complete》ch.7 高质量的子程序

WHAT? 子程序(routines)是为实现一个特定目的而编写的可被调用的方法或过程.在C++中是函数(function),在Java中是方法(method),在VB中是函数过程(function procedure)或子过程(sub procedure). WHY? 降低复杂度 引入中间.易懂的抽象 避免代码重复 支持继承.重写 隐藏实现细节 提高可移植性 改善性能(对明确的子程序进行优化) HOW? 内聚性(cohesion):是指子程序中各种操作之间联系的紧密程度 编程的目标是让每一个子

子程序设计原则

子程序(routines)是为实现一个特定功能而编写的一个可被调用的方法(method).函数(function)或过程(procedure).如Java中的方法,C++里的函数.现代编程语言,如Java.C++.VB.JavaScript.Ruby等都同时支持函数和过程. 一般认为函数指具有返回值的子程序,过程指没有返回值的子程序.C++中把所有子程序成为函数,其实那些返回值为void的函数在语义上也是过程.函数与过程的区别更多是语义上的区别,而不是语法的区别.语言纯化论者认为,一个函数应该只

模块独立性原理

1. 理解模块独立的重要性 2. 掌握模块独立的概念 3. 重点掌握度量模块独立程度的两个标准: 耦合和内聚 5.2.1   模块化 5.2.2   抽象 5.2.3   逐步求精 5.2.4   信息隐藏和局部化 5.2.5   模块独立 5.2.5  模块独立 1. 模块独立的概念: ?是模块化.抽象.信息隐藏和局部化概念的直 接结果. ?是指软件系统中每个模块只完成软件要求的具 体的子功能,而和软件系统中其他模块的接口 尽量简单. 2. 如何做到模块独立? ?开发具有独立功能而且和其他模块

Functional Programming.

I have been seeing Redux for sometime, but recently I come to realize that , it's part of so called functional programming. The basic idea for functional programming is so simple, Declare all dependency as function input, no hidden input ( we should

Functional Programming in Javascript 中文翻译 —— 目录和介绍

原著:[美] Dan Mantyla 目录 前言1 Javascript函数式编程的力量--举个例子2 函数式编程基础3 建立函数式编程环境4 在Javascript中实现函数式编程的技术5 类型理论6 高级主题以及Javascript的缺陷7 Javascript中的函数式和面型对象编程8 Javascript中的函数式和面型对象编程 关于翻译的这本书 现在市面上有两本专注于javascript函数式编程的书,一本是<Functional Javascript>(下文简称FJS), 另一本就

Applied Functional Analysis(Applications to Mathematical Physics ) E.Zeidler

 Applied Functional Analysis(Applications to Mathematical Physics )   E.Zeidler More: QQ565055403