Learn the vocabulary of fixing some of a function's arguments up front to get back a smaller, reusable function.
0 / 5 completed
1 / 5
At standup, a dev mentions fixing some of a function's arguments up front, all at once, and getting back a new function that only needs the remaining arguments supplied to actually run. What is this technique called?
Partial application is exactly this: it fixes some of a function's arguments all at once, up front, and returns a new function that only expects the remaining arguments before it actually runs, unlike currying, which always breaks a function down into a full chain of strictly single-argument steps. A hash collision is an unrelated hash-table concept about two keys sharing a bucket. This fix-several-at-once, get-back-a-smaller-function behavior is exactly what partial application means as a technique in its own right.
2 / 5
During a design review, the team partially applies a logging function's first two arguments, a service name and a log level, specifically so the rest of the codebase can call the resulting function with only the actual log message. Which capability does this provide?
Partial application here provides a specialized, reusable function that already carries fixed context, since the service name and log level are supplied once, up front, and every later call to the resulting function only needs to supply the one piece of information, the message, that actually varies from call to call. Calling the original logging function directly every time would force every call site to repeat the service name and log level explicitly, over and over. This fix-once, reuse-everywhere behavior is exactly why partial application is a common way to specialize a general-purpose function for a specific, repeated context.
3 / 5
In a code review, a dev notices dozens of call sites invoke the same logging function, each one repeating the exact same service name and log level as a literal argument, with only the log message ever actually differing between calls. What does this represent?
This is a missed partial-application opportunity, since fixing the service name and log level once, producing a single specialized function, would let every one of those dozens of call sites share that same function and supply only the actually-varying log message, instead of repeating the identical service name and log level as a literal argument at every call site. A cache eviction policy is an unrelated concept about discarded cache entries. This repeated-literal-argument pattern is exactly the kind of duplication partial application is designed to remove.
4 / 5
An incident report shows a service's log entries were tagged with the wrong log level after a refactor, because dozens of call sites each repeated the log level as a literal argument by hand, and only some of those call sites were updated when the level changed, leaving the rest out of sync. What practice would prevent this?
Partially applying the logging function with the log level fixed once, in a single shared place, produces one function every call site relies on, so a future change to the level only ever needs to be made in that one place and is automatically reflected everywhere, which is exactly the fix for the inconsistency described in this incident. Continuing to repeat the log level as a literal argument by hand at every call site is exactly what let some call sites fall out of sync with the rest after the refactor. This partial-application-based fix removes the repeated, error-prone duplication at its source rather than relying on every call site being updated correctly by hand.
5 / 5
During a PR review, a teammate asks why the team reaches for partial application instead of just currying the logging function fully into single-argument steps, given that both techniques let some arguments be fixed ahead of time. What is the reasoning?
Partial application fixes exactly the arguments actually needed, all at once, in a single step, which tends to read more directly when a function is only ever specialized at one particular boundary, like fixing a service name and log level together. Full currying instead forces every single argument through its own separate step, which is more general but adds a layer of indirection that isn't always useful if the function is never actually partially applied at more than one boundary. The tradeoff is exactly why partial application is often reached for directly when only one specific specialization is needed, while currying is preferred when a function genuinely benefits from being specialized at many different argument boundaries.