← Graph

Null Coalescing Attribute

concept 2 connections

Pattern used in Eventide's Useful-Objects style: a getter defined as `@http_client ||= HttpClient::Substitute.new` (or similar) — if the attribute is still nil, it coalesces into a default value, typically a substitutable null-object implementation of the dependency's interface. Avoids hard-wiring a concrete operational dependency (which would be uncontrollable from tests) while guaranteeing the object is immediately useful. Replaceable by the `dependency` macro from Eventide's Dependency library.

category
pattern
about
Null Coalescing Attribute concept
Walks through replacing a nil dependency with a null-coalescing attribute that defaults to a substitute.
concept Useful Objects
related_to
Null Coalescing Attribute concept
Null-coalescing attributes are how Useful Objects default dependencies without nil-reference errors.

Provenance

Read by
1 extraction