Google Testing Blog: Simplify Your Code: Functional Core, Imperative Shell
Is your code a tangled mess of business logic and side effects? Mixing database calls, network requests, and other external interactions directly with your core logic can lead to code that’s difficult to test, reuse, and understand. Instead, consider writing a functional core that’s called from an imperative shell. Separating your code into functional cores and imperative shells makes it more testable, maintainable, and adaptable. The core logic can be tested in isolation, and the imperative shell can be swapped out or modified as needed. Here’s some messy example code that mixes logic and side effects to send expiration notification emails to users: // Bad: Logic and side effects are mixed function sendUserExpiryEmail(): void { for (const user of db.getUsers()) { if (user.subscriptionEndDate > Date.now()) continue; if (user.isFreeTrial) continue; email.send(user.email, "Your account has expired " + user.name + “.”); } } A functional core should contain pure, testab
Google Testing Blog: Simplify Your Code: Functional Core, Imperative Shell Testing Blog Simplify Your Code: Functional Core, Imperative Shell Monday, October 20, 2025 Google Labels: Arham Jain , TotT    Labels  TotT 113 GTAC 61 James Whittaker 42 Misko Hevery 32 Code Health 31 Anthony Vallone 27 Patrick Copeland 23 Jobs 18 Andrew Trenk 13 C++ 11 Patrik Höglund 8 JavaScript 7 Allen Hutchison 6 George Pirocanac 6 Zhanyong Wan 6 Harry Robinson 5 Java 5 Julian Harty 5 Adam Bender 4 Alberto Savoia 4 Ben Yu 4 Erik Kuefler 4 Philip Zembrod 4 Shyam Seshadri 4 Chrome 3 D
Explore this link on the map →related reading
- Best practices for Claude Code - Claude Code Docsanthropic.com
- An introduction to functional programmingcodewords.recurse.com
- Impeccable: The missing upgrade to Anthropic's impeccable skillimpeccable.style
- Google Testing Blog: Code Healthtesting.googleblog.com
- Paul Buchheit: Communicating with codepaulbuchheit.blogspot.com
- A Bunch of Programming Advice I'd Give To Myself 15 Years Ago | Marcus' Blogmbuffett.com
- The Joel Test: 12 Steps to Better Code – Joel on Softwarejoelonsoftware.com
- A practical introduction to functional programmingmaryrosecook.com
- Google Testing Blog: Less Is More: Principles for Simple Commentstesting.googleblog.com
- Beyond Vibe Coding - A Guide To AI-Assisted Developmentbeyond.addy.ie
- Repeat yourself, do more than one thing, and... — programming is terribleprogrammingisterrible.com
- GitHub - multica-ai/andrej-karpathy-skills: A single CLAUDE.md file to improve Claude Code behavior, derived from Andrej Karpathy's observations on LLM coding pitfalls. · GitHubgithub.com