# When rules collide

> Sometimes two rules meet on one line of code and disagree.

Page: Methodology · Plan
Canonical: https://banes-lab.com/disciplined-methodology/plan#when-rules-collide

This section is stop 25 of 102 in the learning route. Previous: [15 - Ask where it appears](https://banes-lab.com/disciplined-methodology/plan/ask-where-it-appears.md). Next: [01 - Instruction patterns](https://banes-lab.com/pag/patterns/instruction-patterns.md).

Sometimes two rules meet on one line of code and disagree. This method treats that as a boundary between two domains rather than as an exception, and the collision has one resolution, as shown in [E1·a one form](https://banes-lab.com/disciplined-methodology/plan#when-rules-collide-panel-a).

### A tension is a boundary

When two rules conflict, the tempting move is to switch one of them off. A rule is turned off for one file so that another rule can pass, and that file becomes the place where neither rule means anything any more. Two rules that collide come from two different domains, and the collision marks the line between them.

For this reason, when two enforced rules apply to the same code, I look for the one form that satisfies both, and where the rules hold in different scopes, that form is the boundary between the scopes. A tension is resolved in the architecture rather than by disabling one of the rules. In practice, the first step is to find the domain each rule serves, and the second is to find the form that satisfies both. The resolution is recorded once, at the place where the next collision of the same kind will be met, and one rule is never satisfied by breaking the other.

To check this, search for every rule that you or the model switched off. Each one is either a resolved tension with its resolution written down, or an unresolved tension that is still hidden.

Two collisions from this site's own code show how this works. In the first, a rule that bans literal file paths meets a declaration file that has to spell out its own paths. The boundary lies between declaring a path and using one, and the one form is that the declaration file is the single exempt place while every consumer reads the path from it by key. In the second, a rule that every export needs a consumer meets a registry entry that has no consumer until a variant registers itself. The boundary lies between a capability and its use, and the one form is that the [registry pattern](https://banes-lab.com/records/arch/registry-pattern.md) resolves variants by [auto-discovery](https://banes-lab.com/records/arch/auto-discovery.md), so the variant file is the consumer.

The architecture page describes three ways to handle a tension, separating, trading or mitigating, and its principle [a tension has a mechanism](https://banes-lab.com/software-architecture/principles/a-tension-has-a-mechanism.md) decides when a boundary is the answer and when a measured trade-off is. Both rules are right inside their own [bounded context](https://banes-lab.com/records/arch/bounded-context.md), and the line of code sits where the two contexts touch, which is why [explicit boundaries](https://banes-lab.com/records/arch/explicit-boundaries.md) are the first thing to name. Once the boundary is named, the answer carries over: the next collision on the same boundary has the same answer, while a collision on a different boundary is a different tension rather than a precedent.

E1·a one form

```mermaid
flowchart LR
a["Rule A"]
b["Rule B"]
line["One line of code"]
boundary["The domain boundary"]
form["The one form that satisfies both"]
off["One rule switched off"]
a --> line
b --> line
line --> boundary
boundary --> form
line -. the tempting move .-> off
```

## Links to

- [Registry Pattern](https://banes-lab.com/records/arch/registry-pattern.md)
- [Auto-Discovery](https://banes-lab.com/records/arch/auto-discovery.md)
- [A tension has a mechanism](https://banes-lab.com/software-architecture/principles/a-tension-has-a-mechanism.md)
- [Bounded Context](https://banes-lab.com/records/arch/bounded-context.md)
- [Explicit Boundaries](https://banes-lab.com/records/arch/explicit-boundaries.md)

## Linked from

- [Worth before work](https://banes-lab.com/disciplined-methodology/plan/worth-before-work.md)
- [A tension has a mechanism](https://banes-lab.com/software-architecture/principles/a-tension-has-a-mechanism.md)
