Detect Errors Early: From Lean to Shift Left
The fundamental Lean principle that a defect costs exponentially more as it progresses through the value chain applies with particular acuity to software development.
A bug detected in the IDE, at the very moment the developer writes the code, is fixed in seconds: the context is fresh, the correction immediate. The same bug discovered in production, weeks later, requires investigation, reproduction, understanding of lost context, a correction and deployment cycle.
The lead time between defect introduction and resolution lengthens dramatically, and with it the human and organizational cost. Shortening this delay is not a marginal optimization; it’s a qualitative transformation of the process.
Poka-yoke: The Type System as Safeguard
The concept of poka-yoke (error-proofing device) finds its purest expression in the type system.
A strong type is a cognitive poka-yoke: it makes certain errors physically impossible to commit:
- Pass a
UserIdwhere anOrderIdis expected? The compiler refuses. - Forget to handle a case in pattern matching? Compilation error.
These safeguards don’t detect errors after the fact; they prevent them from being born. Like the jig that only allows a part to be inserted in the correct orientation, the type system constrains the space of possible programs to those that respect certain invariants.
The error avoided is infinitely less costly than the error detected.
Jidoka: Stop at Defect
Stop at defect (jidoka, in Japanese) translates to immediate and loud failure rather than silent propagation.
- A unit test that fails locally stops the developer in their tracks, forcing them to fix before continuing
- A linter that signals a violation in the IDE interrupts the writing flow at the precise moment when the correction is trivial
- The CI pipeline that blocks on a red test applies the same principle at the team level
This interruption, apparently costly, prevents the accumulation of defects that would reveal themselves much later in a tangle difficult to unravel. We don’t build on defective foundations, we stop and fix.
The Shift Left Movement
The “shift left” movement formalizes this intuition by systematically pushing verification activities upstream in the development cycle.
Traditionally, tests occurred late: after development, sometimes after integration. Shift left reverses this chronology:
- Unit tests written before or during the code
- Static analysis in the IDE
- Code reviews before merge
- Integration tests in local environment
Each verification shifted to the left of the timeline reduces the feedback loop, accelerates detection, decreases the cost of correction. The asymptotic ideal is instant detection: the error signaled at the very moment it is typed.
Architectural Implications
This strategy has profound architectural implications:
- For unit tests to be executable locally in seconds, the code must be decoupled, its dependencies injectable, its effects isolated
- For static analysis to be useful, types must be expressive and precise
- For feedback to be immediate, tooling must be fast and integrated into the daily workflow
Investing in early detection means investing in testability, modularity, typing quality: properties that improve design well beyond their usefulness for testing.
Lean teaches us that quality is not a cost but an investment; in software development, this investment takes the form of a rigorous type system, fast tests, and tooling that refuses to let defects drift away from their source.
Want to dive deeper into these topics?
We help teams adopt these practices through hands-on consulting and training.
or email us at contact@evryg.com