jargon

Comparison

Ambient contextvsHidden dependency

Ambient context

the code called a static Current property for the clock or the user, and nothing in the signature admitted it.

A dependency reached through static, implicit state — the current time, the current user, the current transaction — rather than passed in. It reads beautifully and is the same trade as a service locator with the indirection removed: hidden coupling, tests that must set and reset global state, and behaviour that depends on what ran before. The two cases people most regret are the clock and the current principal, both of which are trivially injectable.

Full entry →

Hidden dependency

the class needed an environment variable, a file on disk and the current time, and its constructor took nothing.

A dependency a component reaches for without declaring, through a global, a static accessor, an environment lookup or a service locator. The cost is discoverability: you cannot tell what a class needs from its signature, so tests fail with errors about things the test never mentioned. Making them parameters is the whole of the fix, and the resulting long constructor is honest rather than worse.

Full entry →

Related comparisons