Contextpassing
Contextpassing is a programming practice in which execution context information is carried explicitly through a chain of function or method calls by passing a context object or parameter. This approach makes dependencies and control information visible to all callees, rather than relying on implicit or global state. Context often includes user identity, locale, authentication data, deadlines, cancellation signals, tracing identifiers, and configuration.
Common usage patterns occur across languages and paradigms. In functional programming, the Reader monad embodies a
Benefits of contextpassing include clearer dependencies and easier testing, since functions declare their required information rather
Drawbacks include boilerplate and potential performance overhead from repeatedly constructing and passing context objects. Overly large
See also: dependency injection, thread-local storage, context object, continuation-passing style, request-scoped data.