Saltar al contenido principal

Make the bug replayable with a pure function

Identify calculation code that should be pure and separate it from effectful shell code.

functional-programming5 min read

The move: split calculation from environment. A pure function is not a moral preference. It is a debugging tool. When the same inputs always produce the same output, the failure becomes portable: a test fixture, a review comment, a contract example, or a saved production case. When the function also reads time, shared configuration, network state, or a mutable singleton, the failure depends on a world you may not be able to recreate. Use a two-part mental model: The shell gathers facts The shell reads the database, current time, feature flags, request headers, and service responses. It may retry, log,…

Read the full lesson

Sign up free: one personalized lesson every day, matched to your role and goals.

← Back to library

Contáctanos