← Home ← Codex ← DEBT ← Engine
Browse by Category
+ added · updated 7d
← Back to glossary

Types of Cohesion

Code Quality Advanced
debt(d5/e5/b5/t5)
d5 Detectability Operational debt — how invisible misuse is to your safety net

Closest to 'specialist tool catches' (d5). The term's detection_hints list phpmd and phpmetrics as tools that can identify cohesion issues, but automated detection is marked 'no' — these tools flag symptoms (large classes, many responsibilities) rather than directly measuring cohesion type. Recognising coincidental vs functional cohesion still requires human judgment.

e5 Effort Remediation debt — work required to fix once spotted

Closest to 'touches multiple files / significant refactor' (e5). The quick_fix suggests splitting modules with low cohesion, which typically means extracting classes, moving methods, and updating all call sites. This is not a one-line fix but a focused refactoring effort within a component or set of related classes.

b5 Burden Structural debt — long-term weight of choosing wrong

Closest to 'persistent productivity tax' (b5). The term applies across all contexts (web, cli, queue-worker) and is tagged as architectural. Poor cohesion choices compound over time — a coincidentally cohesive Utils class becomes a dumping ground that slows down multiple work streams, but it doesn't fully define the system's shape like a core architectural decision would.

t5 Trap Cognitive debt — how counter-intuitive correct behaviour is

Closest to 'notable trap' (t5). The misconception field states that developers believe 'any grouping of related code counts as good cohesion' when there's actually a spectrum. This is a documented gotcha — developers must learn that logical cohesion (grouping by layer) is worse than functional cohesion, but it's not as severe as concepts where the obvious approach is always wrong.

About DEBT scoring →

Also Known As

functional cohesion sequential cohesion coincidental cohesion

TL;DR

Cohesion grades from Coincidental (worst — random grouping) to Functional (best — single well-defined purpose), guiding module design decisions.

Explanation

Constantine's cohesion spectrum from weakest to strongest: Coincidental (elements grouped arbitrarily — a 'utils' class), Logical (logically similar actions — all I/O routines), Temporal (executed at the same time — startup code), Procedural (follow a sequence), Communicational (share data), Sequential (output of one feeds into next), Functional (all elements contribute to a single well-defined task — ideal). In practice aim for functional or communicational cohesion. Coincidental and logical cohesion produce the most brittle, untestable code. High cohesion combined with low coupling are the two primary structural quality objectives for any module.

Common Misconception

Any grouping of related code counts as good cohesion. Cohesion has a spectrum from coincidental (random grouping) to functional (single well-defined purpose) — grouping by layer (all database code together) is logical cohesion, which is better than coincidental but worse than functional.

Why It Matters

Understanding cohesion types (coincidental → functional) gives a vocabulary for discussing and improving design quality — moving up the scale directly improves maintainability.

Common Mistakes

  • Accepting coincidental cohesion (random grouping) in utility classes without questioning whether the grouping makes sense.
  • Temporal cohesion (things that run at the same time) masquerading as functional cohesion in initialisation classes.
  • Not recognising that most 'Utils' or 'Helpers' classes exhibit coincidental or logical cohesion — split them.
  • Targeting sequential or communicational cohesion as the goal when functional cohesion (single, well-defined purpose) is achievable.

Code Examples

💡 Note
Aim for functional cohesion — each class has one clear purpose. 'Utils' classes are usually coincidental cohesion and should be split.
✗ Vulnerable
// Coincidental cohesion — completely unrelated methods grouped together:
class Utils {
    public function formatDate(DateTime $d): string { /* ... */ }
    public function sendEmail(string $to, string $body): void { /* ... */ }
    public function calculateTax(float $amount): float { /* ... */ }
    // Nothing in common — should be 3 separate classes
}
✓ Fixed
// Types of cohesion (high to low):

// Functional (best) — every element contributes to ONE task
class EmailSender {
    public function send(Email $email): void { /* SMTP logic only */ }
}

// Sequential — output of one element is input of next
class DataPipeline {
    public function run(array $data): array {
        return $this->validate($this->transform($this->load($data)));
    }
}

// Coincidental (worst) — elements grouped by chance
class Utils {  // anti-pattern: unrelated methods lumped together
    public function sendEmail() {}
    public function formatDate() {}
    public function calculateTax() {}
}

Added 15 Mar 2026
Edited 22 Mar 2026
Views 76
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
0 pings S 1 ping M 0 pings T 0 pings W 0 pings T 0 pings F 0 pings S 0 pings S 0 pings M 1 ping T 0 pings W 0 pings T 0 pings F 1 ping S 1 ping S 0 pings M 0 pings T 0 pings W 0 pings T 0 pings F 0 pings S 0 pings S 0 pings M 0 pings T 0 pings W 1 ping T 0 pings F 1 ping S 0 pings S 0 pings M
No pings yet today
No pings yesterday
Amazonbot 8 Ahrefs 6 SEMrush 5 PetalBot 5 Scrapy 4 Perplexity 3 Unknown AI 3 Google 2 ChatGPT 2 Applebot 2 Meta AI 1 Sogou 1 Twitter/X 1 Bing 1 Brave Search 1
crawler 41 crawler_json 3 pre-tracking 1
DEV INTEL Tools & Severity
🟢 Low ⚙ Fix effort: Medium
⚡ Quick Fix
Aim for functional cohesion (one specific task) — if you can only describe a module as doing multiple unrelated things, it has lower cohesion and should be split
📦 Applies To
any web cli queue-worker
🔗 Prerequisites
🔍 Detection Hints
Utility class with unrelated static methods (coincidental cohesion); class that processes different data types differently (logical cohesion)
Auto-detectable: ✗ No phpmd phpmetrics
⚠ Related Problems
🤖 AI Agent
Confidence: Low False Positives: High ✗ Manual fix Fix: High Context: Class Tests: Update


✓ schema.org compliant