jargon

Comparison

Lifetime scopevsSingleton

Lifetime scope

the same registration served one shared instance in one place and a new one per request in another, and that was configuration.

The rule a container uses to decide when to reuse an instance and when to build a fresh one: process-wide, per request or operation, or new every time. It is where most container bugs actually live, because the wrong choice is not a crash — it is state visible across requests, or a connection created per call. Choosing it is a design decision about shared mutable state and should be made deliberately, not defaulted.

Full entry →

Singleton

two tests passed on their own and failed together, because the thing they both reached for kept state between them.

A class that permits exactly one instance and provides global access to it. The instance-count half is almost never the requirement — what people actually want is 'one connection pool', which lifetime configuration in a container gives them without the global. The access half is the damage: an unreplaceable dependency nothing declares, invisible in every signature, and shared across tests that were supposed to be independent.

Full entry →

Related comparisons