encyclopegia.org

Cohesion (computer science)

In computer programming, cohesion refers to the degree to which the elements inside a module belong together.[src] 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.[src] In another sense, it is a measure of the strength of relationship between the class's methods and data.[src] Cohesion is an ordinal type of measurement and is usually described as “high cohesion” or “low cohesion”.[src] Modules with high cohesion tend to be preferable, because high cohesion is associated with several desirable software traits including robustness, reliability, reusability, and understandability.[src] In contrast, low cohesion is associated with undesirable traits such as being difficult to maintain, test, reuse, or understand.[src] Cohesion is often contrasted with coupling.[src] High cohesion often correlates with loose coupling, and vice versa.[src] 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.[src] Structured Design, cohesion and coupling were published in the article Stevens, Myers & Constantine (1974) and the book Yourdon & Constantine (1979).[src] The latter two subsequently became standard terms in software engineering.[src]

In computer programming, cohesion refers to the degree to which the elements inside a module belong together.[src] 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.[src] In another sense, it is a measure of the strength of relationship between the class's methods and data.[src] Cohesion is an ordinal type of measurement and is usually described as “high cohesion” or “low cohesion”.[src] Modules with high cohesion tend to be preferable, because high cohesion is associated with several desirable software traits including robustness, reliability, reusability, and understandability.[src] In contrast, low cohesion is associated with undesirable traits such as being difficult to maintain, test, reuse, or understand.[src] Cohesion is often contrasted with coupling.[src] High cohesion often correlates with loose coupling, and vice versa.[src] 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.[src] Structured Design, cohesion and coupling were published in the article Stevens, Myers & Constantine (1974) and the book Yourdon & Constantine (1979).[src] The latter two subsequently became standard terms in software engineering.[src] /* 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.[src] */ 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).[src] Temporal cohesion: Temporal cohesion is when parts of a module are grouped according to the time in which they are processed.[src] 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).[src] 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).[src] 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).[src] 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).[src] 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).[src] 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.[src] */ 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.[src] 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.[src] */ r(x) = [Module A].a([Module A].b(5, x), 3) } Perfect cohesion (atomic): Example.[src] /* 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.[src] */ 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.[src] Studies by Larry Constantine, Edward Yourdon, and Steve McConnell indicate that the first two types of cohesion are inferior, communicational and sequential cohesion are very good, and functional cohesion is superior.[src]

37 sentences · 37 cited inline · 0 references stored

References

No reference rows published for this article.

Cite this article

MLA

"Cohesion (computer science)." encyclopegia.org, 2025, https://encyclopegia.org/wiki/cohesion-computer-science. Accessed 30 November 2026.

Chicago

"Cohesion (computer science)." encyclopegia.org. Accessed November 30, 2026. https://encyclopegia.org/wiki/cohesion-computer-science.

APA

encyclopegia.org. (2025). Cohesion (computer science). Retrieved November 30, 2026, from https://encyclopegia.org/wiki/cohesion-computer-science

Accessed November 30, 2026 · CC BY-SA 4.0 · citation page · JSON

Claims

PredicateValueSource
publication date1974Wikipedia

Related articles

computer

stub · references available

computer mouse

stub · references available

IBM Personal Computer XT

stub · references available

etymology science

stub · references available

computational science

stub · references available

cognitive science

stub · references available
CC BY-SA 4.0 · share-alike · https://en.wikipedia.org/w/index.php?oldid=1328237301 · 0.5 · snapshot enwiki-001328237301

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools
  • Careers — open roles: frontier engineers and sales partners
  • Index — every corpus, paper and record
  • Estate guide — what a public data estate is
  • Founder — Lois-Kleinner Alpasan
  • Records — DOIs and external deposits
  • Documents — one-pagers, PDFs and QR codes
  • Brand kit — logos and share images
  • Papers — plain-language briefs with citations
  • Browser — search engine, PWA and bookmarklet
  • Anticloud — the operator and its projects

As seen in Business Insider · 336 outlets · evidence DOIs · plain-language papers

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.