![]() ![]() Many of the googled articles on cohesion relate to OO design, but cohesion and coupling are not restricted to OO. 1 : the quality or state of cohering: such as a : systematic or logical connection or consistency The essay as a whole lacks coherence. Lumping unrelated functionality into a single class or component also reduces cohesion.Īs CodeWiki says, cohesion is typically discussed with coupling, where the two can act in opposition to one another, particularly where strict interfaces aren't carefully planned. 2 UNITEif a group has coherence, its members are connected or united because they share common aims, qualities, or beliefs A common religion ensures the. At the same, a given class, module or component should have a single area of responsibility. ![]() Put another way, if your program has to do a given thing, no matter how times or in how many places, for maximum cohesion there should only be once piece of code that does that thing. ![]() If you modify the the original to handle the new case, where the new case is clearly related to the existing functionality, you are increasing cohesion. Thus if you want a function similar to another function, and you cut and paste and subsequently modify a copy of the code, you are reducing cohesion. In addition to the answers given so far, a simple way to think of high cohesion is lack of duplication of functionality, and clear seperation of related functionality into distinct modules, components or classes. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |