白浆是什么| 便秘吃什么润肠通便| 1987年属什么的| 舌头中间裂纹是什么病| 摩羯座属于什么象星座| 血糖低是什么原因引起的| 单飞什么意思| 雌二醇过高是什么原因| 菠菜什么时候传入中国| 荔枝代表什么寓意| 便秘喝什么茶最快排便| 小鱼缸适合养什么鱼| 不全性骨折是什么意思| 狗仗人势是什么生肖| 23岁属什么生肖| 尿道口灼热感吃什么药最快| 猜疑是什么意思| 多囊是什么原因引起的| 游乐场都有什么项目| 丹参有什么功效| iu什么意思| 麻长什么样子图片| 胸腔积液叩诊什么音| 什么叫道德绑架| 向左向右向前看是什么歌| 中药木香的功效与作用是什么| 澳大利亚人说什么语言| 尿隐血阳性是什么病| 尿急尿频吃什么药| 什么高什么低| 错综复杂是什么意思| 知了吃什么东西| 心脏是由什么组织构成的| 蓝天白云是什么生肖| 吃海鲜不能吃什么水果| 莱特兄弟发明了什么| 判处死刑缓期二年执行是什么意思| 金火什么字| 摸摸头是什么意思| 爬山是什么意思| 朱元璋为什么杀蓝玉| 视频是什么意思| triangle是什么意思| 黑t恤搭配什么裤子| 姓许的女孩取什么名字好听| 补铁有什么作用和功效| 9.10是什么星座| 血糖高早餐吃什么好| 什么样的脚好看| 泌尿科看什么病| 辅酶q10什么时候吃| 放炮是什么意思| 克卜勒是什么意思| 比卡丘什么意思| 真丝和桑蚕丝有什么区别| 为什么不能用红笔写名字| 囍是什么意思| 木薯粉是什么做的| 恪尽职守是什么意思| 尿酸高适合吃什么水果| 3岁打什么疫苗| bitch是什么意思| 胃字出头念什么| 屁股又叫什么| 什么药止咳最好| 好饭不怕晚什么意思| 脾胃虚弱吃什么好| 爷们儿大结局是什么| 气短是什么原因| 为什么会得艾滋病| 针眼用什么药| 手心出汗是什么原因| lotus是什么牌子| 女性体寒 吃什么好| 眼睛浮肿什么原因| 梦见彩虹是什么征兆| 喝黄芪水有什么好处| bhcg是什么意思| 女人吃秋葵有什么好处| 什么是糙米| 早泄阳痿吃什么药| 有什么颜色| 兜兜转转是什么意思| 食管在什么位置图片| 胃酸烧心吃什么食物| s925是什么| 鹅蛋炒什么好吃| 94年属狗什么命| 保养是什么意思| 桃李满天下是什么生肖| 白切鸡用什么鸡做好吃| 胆五行属什么| 骨质疏松吃什么好| 疱疹吃什么药好得快| 表水是什么意思| 怀孕可以吃什么| 肺实变是什么意思| 狗为什么喜欢吃屎| 秀女是什么意思| 李字五行属什么| 英国为什么叫日不落帝国| 宝宝咳嗽挂什么科| 女人排卵期什么时候| 6月20号是什么星座| 梅花什么季节开| sch是什么意思| 末伏是什么意思| 舌头发苦是什么原因造成的| 谁的尾巴有什么作用| 龙眼树上的臭虫叫什么| 白细胞2加号什么意思| 无春年是什么意思| 每天泡脚对身体有什么好处| 中位数是什么意思| 什么叫三观| 喉咙挂什么科室| 膀胱钙化是什么意思| 手足口病什么症状| 拍档是什么意思| 14k是什么意思| 月经过后腰酸疼是什么原因| 梦见黑色的蛇是什么意思| 家里镜子放在什么位置比较好| 为什么拉绿色的屎| 偷什么东西不犯法| 韩愈字什么| 两点水有什么字| 临床医学主要学什么| 养尊处优什么意思| 鲨鱼是什么动物| 罗勒是什么| 96199是什么电话| 卵巢囊肿吃什么药好得最快| 奶白色是什么颜色| 刀子嘴豆腐心是什么意思| 中午吃什么饭| 手上长痣代表什么| 人为什么要刷牙| 为什么会眼压高| 月经提前是什么原因引起的| 哀转久绝的绝什么意思| m型发际线适合什么发型| 中核集团是什么级别| 力挽狂澜是什么意思| 宝宝头爱出汗是什么原因| 肚子胀气什么原因| 查肝炎做什么检查项目| pubg是什么意思| 阴虚火旺吃什么水果| 筋膜提升术是什么| 者是什么意思| 女方什么人不能送亲| 大便是绿色的是什么原因| 做梦翻车了什么预兆| 白玫瑰花语是什么意思| 右侧卵巢多囊样改变是什么意思| o型血容易得什么病| 肾结石忌口什么| 毛血旺是什么| ppa是什么意思| 山竹有什么好处| 吃维生素b族有什么好处| 蜂蜜不能和什么一起吃| 耳机降噪是什么意思| 店招是什么意思| 肉是什么结构的字| bolon是什么牌子眼镜| 老是胃疼是什么原因| 乳腺癌ki67是什么意思| 11.1是什么星座| 冠状沟溃疡是什么病| 为什么会得尿毒症| 九月十五是什么星座的| 金匮肾气丸有什么作用| 电饼铛什么牌子好| 为什么不敢挖雍正陵墓| 月月红是什么花| 猫的舌头为什么有刺| 胃胀胃酸是什么原因| 南瓜炒什么好吃| 100001是什么电话| 大腿根部痒用什么药膏| 釜底抽薪是什么计| 一月28号是什么星座| 钢铁锅含眼泪喊修瓢锅这是什么歌| 益母草煮鸡蛋有什么功效| 土中金是什么生肖| 嘴干是什么病的征兆| 一什么田野| 丫丫的老公叫什么| 坐班是什么意思| 高血压吃什么助勃药好| 手指指尖发麻是什么原因| 牙齿有黑线是什么原因| cfu是什么单位| 脑梗吃什么食物好| leonardo是什么牌子| 牙根疼吃什么药最好| 清明节什么时候| 宁五行属什么| 胸部胀痛是什么原因| 试营业是什么意思| 谷雨是什么意思| 膝盖疼是什么原因引起的| 人生三件大事是指什么| 杂面是什么面| 儿童红眼病用什么眼药水| 微信中抱拳是什么意思| 上甘岭在什么地方| 什么的舞台| 什么动物最没有方向感| 法西斯是什么意思啊| 梦见摘辣椒是什么意思| 89年属蛇是什么命| 包是什么意思| 伪军是什么意思| 十一朵玫瑰花代表什么意思| 什么是基础代谢| 男性性功能减退吃什么药| 低压高是什么原因引起的| 为什么肝区隐隐作痛| 最近天气为什么这么热| 尿蛋白定量是什么意思| 老登是什么意思| 去冰和常温有什么区别| 老年人嘴唇发紫是什么原因| 吕布的武器是什么| 梦见下大雨是什么预兆| 县公安局长什么级别| 三高人群适合吃什么水果| 梦见自己在洗澡是什么意思| 舌苔白什么原因| 感觉不到饿是什么原因| 护照需要什么材料| 拉水便吃什么药| 颈椎头晕吃点什么药| 血友病是什么| 石花菜是什么植物| 喝杨梅酒对身体有什么好处| 耳朵热是什么原因| 头寸是什么意思| 血常规能查出什么| 蜈蚣最怕什么| 梦见芹菜是什么意思| 小孩吃火龙果有什么好处| 交公粮是什么意思| 老花镜什么品牌好| 1938年属什么| 二元酸是什么| 援交是什么意思| 电视开不了机是什么原因| 浙江大学什么专业最好| 脾肺气虚吃什么中成药| 孩子为什么长不高| 苦荞茶喝了有什么好处| 身心健康是什么意思| 葡萄糖为什么叫葡萄糖| 胃反流有什么症状| 什么来什么去| 尿液白细胞高是什么原因| 7.7什么星座| 辩驳是什么意思| 舌头白腻厚苔是什么原因| hcy是什么检查项目| 百度Jump to content

港珠澳大桥珠海连接线拱北隧道顺利实现全线贯通

From Wikipedia, the free encyclopedia
百度 ”网友表示,之前整治过,现在又死灰复燃,开始运营起来。

In computer programming, cohesion refers to the degree to which the elements inside a module belong together.[1] In one sense, it is a measure of the strength of relationship between the methods and data of a class and some unifying purpose or concept served by that class. In another sense, it is a measure of the strength of relationship between the class's methods and data.

Cohesion is an ordinal type of measurement and is usually described as “high cohesion” or “low cohesion”. Modules with high cohesion tend to be preferable, because high cohesion is associated with several desirable software traits including robustness, reliability, reusability, and understandability. In contrast, low cohesion is associated with undesirable traits such as being difficult to maintain, test, reuse, or understand.

Cohesion is often contrasted with coupling. High cohesion often correlates with loose coupling, and vice versa.[2] The software metrics of coupling and cohesion were invented by Larry Constantine in the late 1960s as part of Structured Design, based on characteristics of “good” programming practices that reduced maintenance and modification costs. Structured Design, cohesion and coupling were published in the article Stevens, Myers & Constantine (1974)[3] and the book Yourdon & Constantine (1979).[1] The latter two subsequently became standard terms in software engineering.

High cohesion

[edit]

In object-oriented programming, a class is said to have high cohesion if the methods that serve the class are similar in many aspects.[4] In a highly cohesive system, code readability and reusability is increased, while complexity is kept manageable.

Cohesion

Cohesion is increased if:

  • The functionalities embedded in a class, accessed through its methods, have much in common.
  • Methods carry out a small number of related activities, by avoiding coarsely grained or unrelated sets of data.
  • Related methods are in the same source file or otherwise grouped together; for example, in separate files but in the same sub-directory/folder.

Advantages of high cohesion (or "strong cohesion") are:

  • Reduced module complexity, with fewer operations.
  • Increased system maintainability, because logical changes in the domain affect fewer modules, and changes in one module require fewer changes in other modules.
  • Increased module reusability, because application developers will find the component they need more easily among the cohesive set of operations provided by the module.

While in principle a module can have perfect cohesion by only consisting of a single, atomic element – having a single function, for example – in practice complex tasks are not expressible by a single, simple element. Thus a single-element module has an element that is either too complicated to accomplish a task, or too narrow and thus tightly coupled to other modules. Thus cohesion is balanced with both unit complexity and coupling.

Types of cohesion

[edit]

Cohesion is a qualitative measure, meaning that the source code is examined using a rubric to determine a classification. Cohesion types, from the worst to the best, are as follows:

Coincidental cohesion (worst)
Coincidental cohesion is when parts of a module are grouped arbitrarily. The only relationship between the parts is that they have been grouped together (e.g., a “Utilities” class). Example:
/*
Groups: The function definitions
Parts: The terms on each function
*/
Module A {
  /*
  Implementation of r(x) = 5x + 3
  There is no particular reason to group functions in this way,
  so the module is said to have Coincidental Cohesion.
  */ 
  r(x) = a(x) + b(x) 
  a(x) = 2x + 1
  b(x) = 3x + 2
}
Logical cohesion
Logical cohesion is when parts of a module are grouped because they are logically categorized to do the same thing even though they are different by nature (e.g., grouping all mouse and keyboard input handling routines or bundling all models, views, and controllers in separate folders in an MVC pattern).
Temporal cohesion
Temporal cohesion is when parts of a module are grouped according to the time in which they are processed. The parts are processed at a particular time in program execution (e.g., a function that is called after catching an exception that closes open files, creates an error log, and notifies the user).
Procedural cohesion
Procedural cohesion is when parts of a module are grouped because they always follow a certain sequence of execution (e.g., a function that checks file permissions and then opens the file).
Communicational/informational cohesion
Communicational cohesion is when parts of a module are grouped because they operate on the same data (e.g., a module that operates on the same record of information).
Sequential cohesion
Sequential cohesion is when parts of a module are grouped because the output from one part is the input to another part like an assembly line (e.g., a function that reads data from a file and processes the data).
Functional cohesion (best)
Functional cohesion is when parts of a module are grouped because they all contribute to a single well-defined task of the module (e.g., Lexical analysis of an XML string). Example:
/*
Groups: The function definitions
Parts: The terms on each function
*/
Module A {
  /*
  Implementation of arithmetic operations
  This module is said to have functional cohesion because 
  there is an intention to group simple arithmetic operations
  on it. 
  */
  a(x, y) = x + y
  b(x, y) = x * y
}

Module B {
  /*
  Module B: Implements r(x) = 5x + 3
  This module can be said to have atomic cohesion. The whole
  system (with Modules A and B as parts) can also be said to have functional
  cohesion, because its parts both have specific separate purposes. 
  */
  r(x) = [Module A].a([Module A].b(5, x), 3)
}
Perfect cohesion (atomic)
Example.
/*
Groups: The function definitions
Parts: The terms on each function
*/
Module A {
  /* 
  Implementation of r(x) = 2x + 1 + 3x + 2
  It's said to have perfect cohesion because it cannot be reduced any more than that.
  */
  r(x) = 2x + 1 + 3x + 2
}

Although cohesion is a ranking type of scale, the ranks do not indicate a steady progression of improved cohesion. Studies by Larry Constantine, Edward Yourdon, and Steve McConnell[5] indicate that the first two types of cohesion are inferior, communicational and sequential cohesion are very good, and functional cohesion is superior.

See also

[edit]

References

[edit]
  1. ^ a b Yourdon, Edward; Constantine, Larry LeRoy (1979) [1975]. Structured Design: Fundamentals of a Discipline of Computer Program and Systems Design. Yourdon Press. Bibcode:1979sdfd.book.....Y. ISBN 978-0-13-854471-3.
  2. ^ Ingeno, Joseph (2018). Software Architect's Handbook. Packt Publishing. p. 175. ISBN 978-178862406-0.
  3. ^ Stevens, Wayne P.; Myers, Glenford J.; Constantine, Larry LeRoy (June 1974). "Structured design". IBM Systems Journal. 13 (2): 115–139. doi:10.1147/sj.132.0115.
  4. ^ Marsic, Ivan (2012). Software Engineering. Rutgers University.
  5. ^ McConnell, Steve (June 2004) [1993]. Code Complete (2 ed.). Pearson Education. pp. 168-171. ISBN 978-0-7356-1967-8.
[edit]
吃什么润肠通便 辛辣都包括什么 泌尿外科看什么病 去三亚穿什么衣服合适 什么时候喝牛奶效果最佳
富翁是什么意思 为什么叫马桶 关联词是什么意思 布丁是用什么做的 阴道红肿是什么原因
嫡长子是什么意思 杜牧字什么号什么 看日出是什么生肖 1988年属什么今年多大 吃无花果干有什么好处
心神不定是什么生肖 风湿免疫科是什么病 什么是腐女 白板是什么意思 奋笔疾书的疾是什么意思
干涸是什么意思bjcbxg.com 缘字五行属什么hcv9jop4ns0r.cn 什么是自慰hcv8jop3ns2r.cn 什么的梦hcv9jop3ns0r.cn 胰岛素是什么器官分泌的hcv9jop2ns0r.cn
历年是什么意思hcv7jop9ns5r.cn 什么的身子hcv8jop4ns9r.cn 碘吃多了有什么危害hcv8jop9ns9r.cn 头发稀少是什么原因导致的xjhesheng.com spa是什么0297y7.com
b超跟彩超有什么区别hcv8jop2ns4r.cn 女性备孕吃什么养卵泡hcv9jop1ns9r.cn 小便多是什么原因bfb118.com 方阵是什么意思hcv8jop0ns2r.cn 戌时右眼跳是什么预兆hcv8jop7ns7r.cn
孩子走路晚是什么原因tiangongnft.com 什么的仪式hcv9jop5ns0r.cn 1985属什么hcv8jop4ns5r.cn 禾加一笔是什么字hcv9jop2ns2r.cn 石花膏是什么做的0735v.com
百度