Inappropriate Intimacy: What It Costs and How to Fix It
Two classes that depend too heavily on each other's internal details, creating a tangled, inseparable pair.
What It Is
Inappropriate Intimacy occurs when two classes know too much about each other's internal implementation. They access each other's private or protected members, depend on each other's internal data structures, and cannot be understood, tested, or deployed independently. The coupling is bidirectional: Class A depends on B's internals and B depends on A's internals, creating a tightly bound pair that effectively functions as a single, oversized class split across two files.
Why It Costs Money
Neither class can be changed independently. Any modification to one class's internals requires checking and potentially updating the other class. This doubles the effort for every change and makes code review more complex because reviewers must understand both classes simultaneously.
Testing in isolation is impossible. You cannot test Class A without setting up Class B in a specific internal state, and vice versa. This creates fragile test suites where a change in one class breaks tests for both.
Reuse is blocked. Neither class can be extracted for use in another context because it drags its partner along. The pair becomes an inseparable unit that must be maintained as a whole.
Specific Cost Mechanisms
- ●Coupled changes: every modification requires understanding and updating two classes, doubling effort
- ●Test fragility: changes to either class break tests for both classes
- ●Reuse prevention: the coupled pair cannot be extracted or reused independently
Estimated Annual Cost
Cost of one instance a year by team size, from our model at $180K fully-loaded cost per engineer. Low and high use the bottom and top of the High inputs; mid is halfway. See full methodology.
| Team Size | Low | Mid | High |
|---|---|---|---|
| 3 devs | $4K | $9K | $15K |
| 5 devs | $6K | $14K | $23K |
| 8 devs | $10K | $22K | $35K |
| 10 devs | $12K | $27K | $43K |
| 20 devs | $23K | $53K | $83K |
These are model outputs, not measurements. Every input is on the cost model page, and the same model produces the figures on the 22 smells page. Put in your own team and cost in the smell profile calculator.
How to Detect It
Specific rules and thresholds for automated detection. See full tool comparison.
High bidirectional class coupling
Classes that reference each other heavily
Counts the number of unique types referenced by a class
Bidirectional imports between modules indicate intimacy
Refactoring Patterns
Proven techniques to eliminate this smell. See all refactoring patterns.
Move Method/Field
One class has methods that primarily use the other class's data
Extract Class
The shared behaviour between both classes forms a coherent concept
Hide Delegate
One class exposes its internal collaborator to the other