A critique of cohesion measures in the object-oriented parad(3)
Cohesion refers to the "relatedness " of a module's components. In the object-oriented paradigm, cohesion refers to the "relatedness " among the methods of a class. Most of the current measures of cohesion in the object-oriented paradig
Buxton and Macro 10] extended the original seven levels of cohesion to include another type of cohesion which included modules that encapsulate abstract data types. They called this abstract cohesion or data cohesion. Fenton 18], describes such cohesion as a completely di erent type of cohesion and disagrees that it is an extension of the original seven levels of cohesion. This type of cohesion characterizes a data type as cohesive because the operations are performed on a single object. Thus a module in this case can perform a variety of functions, which are related by the abstract data type they characterize. Unlike the procedural programming paradigm where a module is de ned to be a procedure or a function, in the object-oriented paradigm we de ne a module to be a class. A class with a private representation of data elements and a public set of methods is referred to as an abstract data type. A class has several methods that perform certain functions on the class data type. Consider the list class described in Figure 2.1. Here we see that each method of the class uses the data elements head and tail to de ne various operations that can be performed on a LIST of objects, such as, append, remove, and is empty. All the methods are operating on a single LIST object. The list class encapsulating the abstract data type, LIST. Hence, the list class can be considered to be a cohesive class.
5
Cohesion refers to the "relatedness " of a module's components. In the object-oriented paradigm, cohesion refers to the "relatedness " among the methods of a class. Most of the current measures of cohesion in the object-oriented paradig
list::list(){ head= NULL; tail= NULL;} list::~list(){ remove();} void list::append(Type someitem){ item *pt; pt= new item(someitem); assert (pt != 0); if (is_empty()){ head= pt;} else{ tail->next= pt;} pt->next= NULL; tail= pt;} void list::remove(){ item *pt; item *temp; pt= head; while (pt){ temp= pt; pt= pt->next; delete(temp);} head= tail= NULL; cout<<"Removed all list elements"<<"\n";} boolean list::is_empty(){ if (head== NULL) return(true) else return(false);}
6
Figure 2.1: LIST class encapsulates abstract data type LIST and performs all operations on a LIST of objects as presented in a standard text 27].
Cohesion refers to the "relatedness " of a module's components. In the object-oriented paradigm, cohesion refers to the "relatedness " among the methods of a class. Most of the current measures of cohesion in the object-oriented paradig
Chapter 3
Existing Cohesion Measures in the Object-Oriented ParadigmHer
e we will be presenting some measures that have been proposed by researchers for measuring cohesion in the object-oriented paradigm. Some of the measures like LCOM, Connectivity metric, Chen and Lu's cohesion measure, and Bieman and Kang's cohesion measure are claimed to measure cohesion in the object-oriented paradigm. We, too, propose a cohesion measure in the object-oriented paradigm which is a modi cation of the slice-based functional cohesion measure in the procedural paradigm.
3.1 The Lack of Cohesion in Methods MetricChidamber and Kemerer 12] have proposed a cohesion measure called Lack of Cohesion in Methods, LCOM, based on the number of disjoint sets of instance variables that are used by the method. The cohesion of the class is inversely related to the number of disjoint sets, i.e., the smaller the number of disjoint sets the more cohesive the class is assumed to be. Li and Henry 19] attempted to rephrase the de nition of LCOM given by Chidamber and Kemerer in order to overcome the ambiguity in the original de nition. Chidamber and Kemerer 13] later revised their own de nition for LCOM and formally restated it as follows: Consider a class C1 with n methods M1, M2, . . ., Mn . Let Ij= set of instance variables used by the method Mj . There are n such sets I1,...,In. Let P= f (Ii,Ij ) j Ii\ Ij=;g and Q= f (Ii,Ij ) j Ii\ Ij 6=; g If all n sets I1,...,In are; then let P= 0.
LCOM=
(
jP j? jQj; if jP j> jQj0 otherwise 7
Cohesion refers to the "relatedness " of a module's components. In the object-oriented paradigm, cohesion refers to the "relatedness " among the methods of a class. Most of the current measures of cohesion in the object-oriented paradig
LCOM= 0 indicates a cohesive class since all the methods share instance variables. Hence the class need not be split. For LCOM> 0, the class needs to be or can be split into two or more classes since the instance variables belong in disjoint sets.
3.2 Connectivity MetricHitz and Montazeri 21], present a graph theoretic version of the cohesion metric proposed by Chidamber and Kemerer. They formulate a regression model for measuring the quality of software both at run-time and during the maintenance phase based on their metric. They de ne LCOM as follows: Consider a class X with a set of instance variables, IX, and a set of methods of the class, MX . Let GX (V,E) be a simple undirected graph representing the methods of the class, where V= MX and E= f(m; n) 2 V V j (9 i 2 IX: (m accesses i)^ (n accesses i)) _ (m calls n) _ (n calls m)g LCOM(X) is then de ned as the number of connected components of GX, where 1 LCOM (X ) jMX j where\m accesses i" means that m uses instance variable i.\m calls n" means that they share a common instance variable. For classes with more than two methods, they re ne the LCOM further to be able to measure the structural di erence between the methods of a set of classes with the same val …… 此处隐藏:6296字,全部文档内容请下载后查看。喜欢就下载吧 ……
相关推荐:
- [教育文库]夜场KTV服务员的岗位职责及工作流程[1]
- [教育文库]企划、网络、市场绩效考核方案
- [教育文库]学党史、知党情、强党性--“党的基本理
- [教育文库]2016年高考物理大一轮总复习(江苏专版
- [教育文库]干部廉洁自律自查自纠的报告
- [教育文库]2010年北京大学心理学系拟录取硕士研究
- [教育文库]资金时间价值练习题及答案
- [教育文库]保护环境的心得体会
- [教育文库]英语角内容:英语趣味小知识
- [教育文库]档案收集与管理工作通知
- [教育文库]劳动规章制度范本范本
- [教育文库]高考物理一轮复习课后限时作业1运动的
- [教育文库]机械工艺夹具毕业设计195推动架设计说
- [教育文库]通用技术教学比赛说课稿2
- [教育文库]2018年四年级英语下册 Module 7 Unit 2
- [教育文库]第2章 宽带IP网络的体系结构
- [教育文库]九年级化学第五单元课题3《根据化学方
- [教育文库]小学英语六年级情态动词用法归纳
- [教育文库]甲级单位编制窑井盖项目可行性报告(立
- [教育文库]2016-2021年中国城市规划行业全景调研
- 高考英语听力十大场景词汇总结
- 全省领导班子思想政治建设座谈会会议精
- 人教版新课标高一英语提优竞赛试题 下
- 江西省2014年生物中考试题
- 长沙镇食品药品安全事故应急预案
- 《金刚石、石墨和C60》片段教学设计
- 福州教育学院(王旭东)
- 基于EDA音乐播放器的设计
- 9、古诗两首《夜书所见》《九月九日忆
- 小学语文课外阅读有效策略探讨
- 贵州文化产业发展成支柱产业的问卷调查
- 膀胱类癌的诊治体会(附3例报告)
- 发动机积碳产生的原因
- Configuring Code Composer Studio for
- 学生良好的心理素质如何培养点滴谈
- 46 电沉积法制备锂离子电池用硅-锂薄膜
- 美舍雅阁公司管理中各部门职责
- 去壳剥皮的小妙招
- 六自由度运动平台的仿真研究
- Pride and Prejudice(傲慢与偏见)




