← CodeClarityLab Home
Browse by Category
+ added · updated 7d
← Back to glossary

Types of Coupling

quality Advanced
debt(d7/e5/b7/t5)
d7 Detectability Operational debt — how invisible misuse is to your safety net

Closest to 'only careful code review or runtime testing' (d7). The term's detection_hints indicate automated detection is 'no'. Identifying coupling types (content, common, control, stamp, data) requires human judgment during code review. No static analysis tools reliably detect these architectural patterns; a developer must understand the semantic relationships between modules to classify the coupling type.

e5 Effort Remediation debt — work required to fix once spotted

Closest to 'touches multiple files / significant refactor in one component' (e5). The quick_fix is vague ('review documentation'), but common_mistakes reveal fixes like splitting control-coupled methods into two separate methods, eliminating global mutable state, or refactoring Reflection hacks. These are not one-line fixes but targeted refactors within specific components. Worse cases (content coupling via public properties throughout) could push toward e7.

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

Closest to 'strong gravitational pull' (b7). Coupling types represent foundational architectural patterns that apply across web and cli contexts. Once content or common coupling pervades a codebase, every future change must navigate around it. The choice to allow or prevent specific coupling types shapes how modules interact system-wide, creating persistent architectural gravity that influences all subsequent development.

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

Closest to 'notable trap' (t5). The misconception field explicitly states the trap: 'All forms of coupling are equally bad.' Developers often treat coupling as binary (bad vs. good) rather than understanding the spectrum from acceptable data coupling to harmful content coupling. This is a documented gotcha that developers eventually learn, but the initial intuition that 'all coupling is bad' leads to over-engineering or misplaced refactoring priorities.

About DEBT scoring →

Also Known As

content coupling data coupling stamp coupling control coupling

TL;DR

Coupling grades from Content (worst — direct internal access) to Message (best — pure interface communication), guiding decoupling decisions.

Explanation

Constantine's coupling spectrum tightest to loosest: Content (one module modifies another's internals directly — worst), Common (modules share global state), External (modules share an external data format), Control (one module directs another's flow via flag parameters), Stamp (modules share a data structure but use different parts), Data (modules share only necessary data via parameters — good), Message (modules communicate only via messages or interfaces — best). In PHP, common coupling via global variables or static state is the most frequent violation. Data and message coupling — achieved through constructor injection and interfaces — are the targets.

Common Misconception

All forms of coupling are equally bad. Data coupling (passing only needed data) is acceptable; content coupling (one module reaching into another's internals) is the most harmful. Understanding the type helps prioritise which coupling to reduce first.

Why It Matters

Naming coupling types (content, common, control, stamp, data) gives teams precise language to discuss and eliminate specific coupling problems rather than vague 'too coupled' feedback.

Common Mistakes

  • Content coupling (modifying another class's internals) — often via public properties or Reflection hacks.
  • Common coupling (shared global mutable state) — global variables, static properties, and some singleton uses.
  • Control coupling (passing a flag to change a method's behaviour) — split into two separate methods instead.
  • Not recognising stamp coupling (passing a whole object when only one field is needed) — pass just the needed value.

Code Examples

✗ Vulnerable
// Control coupling — flag changes internal behaviour:
function processOrder(Order $o, bool $sendEmail): void {
    // ... process ...
    if ($sendEmail) $this->mailer->send($o); // Split into processOrder + notifyCustomer
}
✓ Fixed
// Content coupling (worst) — directly accesses another class's internals
// \$obj->internalData['key'] — reaches inside private state

// Control coupling — passes a flag that controls other class's behaviour
// process(\$data, doLogging: true) — caller controls callee's internals

// Data coupling (best) — passes only needed data, receives only needed output
class TaxCalculator {
    public function calculate(float \$amount, TaxRate \$rate): float {
        return \$amount * \$rate->value(); // minimal interface
    }
}

// Aim for data coupling — pass only what's needed, return a value
// Avoid content + control coupling — they make classes hard to change independently

Added 15 Mar 2026
Edited 22 Mar 2026
Views 18
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
0 pings F 0 pings S 1 ping S 0 pings M 0 pings T 1 ping W 0 pings T 0 pings F 0 pings S 1 ping S 0 pings M 0 pings T 2 pings W 0 pings T 0 pings F 0 pings S 0 pings S 0 pings M 0 pings T 1 ping W 1 ping T 0 pings F 0 pings S 0 pings S 0 pings M 0 pings T 2 pings W 0 pings T 0 pings F 0 pings S
No pings yet today
No pings yesterday
Amazonbot 9 Unknown AI 3 Perplexity 2 Google 2 Ahrefs 1
crawler 15 crawler_json 1 pre-tracking 1
DEV INTEL Tools & Severity
🟢 Low ⚙ Fix effort: Medium
⚡ Quick Fix
Review the Types of Coupling documentation and apply to your PHP project context
📦 Applies To
any web cli
🔗 Prerequisites
🔍 Detection Hints
Absence or misuse of Types of Coupling patterns
Auto-detectable: ✗ No
⚠ Related Problems
🤖 AI Agent
Confidence: Medium False Positives: High ✗ Manual fix Fix: High Context: Class Tests: Update

✓ schema.org compliant