From 8e3470f127fb7146b2470dda794e1b3527531be4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=7BAI=7Df=20D=2E=20M=C3=BCller?= Date: Tue, 7 Apr 2026 16:00:53 +0200 Subject: [PATCH] feat: add Cohesion Criteria (Constantine & Yourdon) anchor Seven levels of module cohesion from coincidental to functional. Proposed by Gernot Starke. Co-Authored-By: Claude Opus 4.6 (1M context) --- docs/anchors/cohesion-criteria.adoc | 53 +++++++++++++++++++ docs/anchors/cohesion-criteria.de.adoc | 53 +++++++++++++++++++ docs/changelog.adoc | 6 +++ .../references/catalog.md | 5 ++ .../references/catalog.md | 5 ++ 5 files changed, 122 insertions(+) create mode 100644 docs/anchors/cohesion-criteria.adoc create mode 100644 docs/anchors/cohesion-criteria.de.adoc diff --git a/docs/anchors/cohesion-criteria.adoc b/docs/anchors/cohesion-criteria.adoc new file mode 100644 index 0000000..76b1280 --- /dev/null +++ b/docs/anchors/cohesion-criteria.adoc @@ -0,0 +1,53 @@ += Cohesion Criteria +:categories: design-principles +:roles: software-architect, software-developer, consultant, educator +:related: grasp, solid-srp, clean-architecture, vertical-slice-architecture +:proponents: Larry Constantine, Edward Yourdon +:tags: cohesion, coupling, module design, structured design, code quality +:tier: 2 + +[%collapsible] +==== +Full Name:: Cohesion Criteria (Constantine & Yourdon) + +Also known as:: Levels of Cohesion, Cohesion Scale, Module Cohesion Types + +[discrete] +== *Core Concepts*: + +Seven levels of cohesion, ranked from worst (1) to best (7): + +Coincidental Cohesion (1):: Elements are grouped arbitrarily with no meaningful relationship. Typical sign: utility classes or grab-bag modules. + +Logical Cohesion (2):: Elements perform similar activities selected by a control flag. Example: a function handling all I/O (read, write, print) chosen by a parameter. + +Temporal Cohesion (3):: Elements are grouped because they execute at the same time. Example: startup initialization routines bundled together. + +Procedural Cohesion (4):: Elements are grouped because they follow a specific execution sequence. Example: a function that validates input, then opens a file, then writes a log. + +Communicational Cohesion (5):: Elements operate on the same data but perform different operations. Example: a module that both validates and formats a customer record. + +Sequential Cohesion (6):: The output of one element serves as input to the next, forming a pipeline. Example: parse -> validate -> transform. + +Functional Cohesion (7):: Every element contributes to a single, well-defined task. The ideal. Example: `calculateShippingCost()` does exactly one thing. + + +Key Proponents:: Larry Constantine and Edward Yourdon ("Structured Design", 1979). Further developed by Meilir Page-Jones ("The Practical Guide to Structured Systems Design", 1988). + +[discrete] +== *When to Use*: + +* Evaluating module quality during code reviews or refactoring +* Deciding whether to split a class or module that feels too large +* Arguing for refactoring with concrete criteria instead of gut feeling +* Teaching software design: the scale makes abstract quality tangible +* Assessing architecture decisions around module boundaries + +[discrete] +== *Related Anchors*: + +* <> - "High Cohesion" is one of the nine GRASP patterns +* <> - Single Responsibility Principle targets functional cohesion +* <> - Organizes code by cohesive business rules +* <> - Groups by feature cohesion rather than technical layer +==== diff --git a/docs/anchors/cohesion-criteria.de.adoc b/docs/anchors/cohesion-criteria.de.adoc new file mode 100644 index 0000000..d543634 --- /dev/null +++ b/docs/anchors/cohesion-criteria.de.adoc @@ -0,0 +1,53 @@ += Kohäsionskriterien +:categories: design-principles +:roles: software-architect, software-developer, consultant, educator +:related: grasp, solid-srp, clean-architecture, vertical-slice-architecture +:proponents: Larry Constantine, Edward Yourdon +:tags: cohesion, coupling, module design, structured design, code quality +:tier: 2 + +[%collapsible] +==== +Vollständiger Name:: Kohäsionskriterien (Constantine & Yourdon) + +Auch bekannt als:: Kohäsionsstufen, Kohäsionsskala, Modulkohäsionstypen + +[discrete] +== *Kernkonzepte*: + +Sieben Stufen der Kohäsion, geordnet von schlecht (1) bis ideal (7): + +Zufällige Kohäsion (1):: Elemente sind willkürlich gruppiert, ohne sinnvollen Zusammenhang. Typisches Zeichen: Utility-Klassen oder Sammelmodule. + +Logische Kohäsion (2):: Elemente führen ähnliche Aktivitäten aus, die über ein Steuerflag ausgewählt werden. Beispiel: eine Funktion für alle I/O-Operationen (lesen, schreiben, drucken), gesteuert durch einen Parameter. + +Temporale Kohäsion (3):: Elemente sind gruppiert, weil sie zur gleichen Zeit ausgeführt werden. Beispiel: Initialisierungsroutinen beim Programmstart. + +Prozedurale Kohäsion (4):: Elemente sind gruppiert, weil sie einer bestimmten Ausführungsreihenfolge folgen. Beispiel: eine Funktion, die Eingaben validiert, dann eine Datei öffnet, dann ein Log schreibt. + +Kommunikative Kohäsion (5):: Elemente arbeiten auf denselben Daten, führen aber unterschiedliche Operationen aus. Beispiel: ein Modul, das einen Kundendatensatz sowohl validiert als auch formatiert. + +Sequentielle Kohäsion (6):: Die Ausgabe eines Elements dient als Eingabe des nächsten, eine Pipeline bildend. Beispiel: parsen -> validieren -> transformieren. + +Funktionale Kohäsion (7):: Jedes Element trägt zu genau einer wohldefinierten Aufgabe bei. Das Ideal. Beispiel: `berechneVersandkosten()` tut genau eine Sache. + + +Hauptvertreter:: Larry Constantine und Edward Yourdon ("Structured Design", 1979). Weiterentwickelt von Meilir Page-Jones ("The Practical Guide to Structured Systems Design", 1988). + +[discrete] +== *Wann verwenden*: + +* Bewertung der Modulqualität bei Code Reviews oder Refactoring +* Entscheidung, ob eine Klasse oder ein Modul aufgeteilt werden sollte +* Argumentation für Refactoring mit konkreten Kriterien statt Bauchgefühl +* Lehre im Softwaredesign: die Skala macht abstrakte Qualität greifbar +* Bewertung von Architekturentscheidungen zu Modulgrenzen + +[discrete] +== *Verwandte Anker*: + +* <> - "High Cohesion" ist eines der neun GRASP-Patterns +* <> - Single Responsibility Principle zielt auf funktionale Kohäsion +* <> - Organisiert Code nach kohäsiven Geschäftsregeln +* <> - Gruppiert nach Feature-Kohäsion statt technischer Schicht +==== diff --git a/docs/changelog.adoc b/docs/changelog.adoc index f8077cc..e255535 100644 --- a/docs/changelog.adoc +++ b/docs/changelog.adoc @@ -2,6 +2,12 @@ A chronological record of all semantic anchors added to the catalog. Community contributors are credited with thanks. +== 2026-04-07 + +*New anchors* (proposed by Gernot Starke): + +* *Cohesion Criteria (Constantine & Yourdon)* — Seven levels of module cohesion from coincidental to functional + == 2026-04-01 *New anchors:* diff --git a/plugins/semantic-anchors/skills/semantic-anchor-translator/references/catalog.md b/plugins/semantic-anchors/skills/semantic-anchor-translator/references/catalog.md index 148b0e6..727e392 100644 --- a/plugins/semantic-anchors/skills/semantic-anchor-translator/references/catalog.md +++ b/plugins/semantic-anchors/skills/semantic-anchor-translator/references/catalog.md @@ -181,6 +181,11 @@ Source: https://github.com/LLM-Coding/Semantic-Anchors - **Proponents:** Craig Larman - **Core:** 9 patterns for OO responsibility assignment — Information Expert, Creator, Controller, Low Coupling, High Cohesion, Polymorphism, Pure Fabrication, Indirection, Protected Variations +### Cohesion Criteria (Constantine & Yourdon) +- **Also known as:** Levels of Cohesion, Cohesion Scale, Module Cohesion Types +- **Proponents:** Larry Constantine, Edward Yourdon +- **Core:** 7 levels of module cohesion from worst to best — Coincidental (arbitrary grouping), Logical (similar activities via flag), Temporal (same time), Procedural (execution sequence), Communicational (same data), Sequential (pipeline), Functional (single task, ideal) + ### CRC-Cards - **Also known as:** CRC Cards, Class-Responsibility-Collaboration Cards - **Proponents:** Ward Cunningham, Kent Beck diff --git a/skill/semantic-anchor-translator/references/catalog.md b/skill/semantic-anchor-translator/references/catalog.md index 148b0e6..727e392 100644 --- a/skill/semantic-anchor-translator/references/catalog.md +++ b/skill/semantic-anchor-translator/references/catalog.md @@ -181,6 +181,11 @@ Source: https://github.com/LLM-Coding/Semantic-Anchors - **Proponents:** Craig Larman - **Core:** 9 patterns for OO responsibility assignment — Information Expert, Creator, Controller, Low Coupling, High Cohesion, Polymorphism, Pure Fabrication, Indirection, Protected Variations +### Cohesion Criteria (Constantine & Yourdon) +- **Also known as:** Levels of Cohesion, Cohesion Scale, Module Cohesion Types +- **Proponents:** Larry Constantine, Edward Yourdon +- **Core:** 7 levels of module cohesion from worst to best — Coincidental (arbitrary grouping), Logical (similar activities via flag), Temporal (same time), Procedural (execution sequence), Communicational (same data), Sequential (pipeline), Functional (single task, ideal) + ### CRC-Cards - **Also known as:** CRC Cards, Class-Responsibility-Collaboration Cards - **Proponents:** Ward Cunningham, Kent Beck