Skip to main content
GB

Gary Bernhardt

1episode
1podcast

We have 1 summarized appearance for Gary Bernhardt so far. Browse all podcasts to discover more episodes.

Featured On 1 Podcast

All Appearances

1 episode

AI Summary

→ WHAT IT COVERS Gary Bernhardt explains why he rebuilt Execute Program as a full-stack TypeScript application, detailing how static typing reduces test requirements by 80% while maintaining code quality through strategic testing of core logic layers. → KEY INSIGHTS - **Test reduction through types:** TypeScript enables a 4:1 production-to-test code ratio compared to typical 1:2 ratios in dynamic languages. The entire React frontend has zero component tests, relying instead on type checking and minimal Cypress smoke tests covering all lessons. - **Runtime validation with IOTs:** IOTs library solves TypeScript's type erasure problem by defining schemas that generate both runtime validation and static types from a single definition. This allows untrusted API request data to safely enter the typed system without manual synchronization between validators and types. - **Conditional code placement:** Push conditional logic deeper into system layers rather than at API endpoints or controllers. Testing database models directly requires no HTTP request setup and runs orders of magnitude faster, while TypeScript guarantees the wiring between layers works correctly without explicit tests. - **Discriminated unions for state:** Use literal types with a "kind" property to model exclusive states. Execute Program defines five user subscription states as literal string unions, ensuring every switch statement handles all cases. Adding a sixth state triggers compile errors at every location requiring updates. - **Structural typing flexibility:** TypeScript's structural type system allows union types to combine existing types without modifying source code or introducing artificial base classes. Functions accepting "user or group" unions can be created without touching either original type definition, containing complexity within the function itself. → NOTABLE MOMENT Bernhardt reveals that changing a database column type automatically cascades through the entire stack via TypeScript errors, guiding developers from database layer through API handlers to React components. This eliminates the forgotten edge cases that tests cannot anticipate, catching issues no test suite would find. 💼 SPONSORS None detected 🏷️ TypeScript, Static Typing, Test Strategy, Type Systems, Software Architecture

Never miss Gary Bernhardt's insights

Subscribe to get AI-powered summaries of Gary Bernhardt's podcast appearances delivered to your inbox weekly.

Start Free Today

No credit card required • Free tier available