More Podcasts by InfoQ episodes

Do Functional Programming and Agents Play Well Together Towards Improved Code Quality and Testing? thumbnail

Do Functional Programming and Agents Play Well Together Towards Improved Code Quality and Testing?

Published 30 Nov 2026

Duration: 00:28:20

Functional programming's modularity and purity optimize AI agent performance, while active developer engagement and layered testing strategies remain critical for reliable code generation.

Episode Description

In this episode, Uberto Barbini discusses how clean functional programming can help AI Agents to generate better code. He explains how immutable data...

Overview

Uberto Barbini, a long-running software developer who shifted from object-oriented programming to functional programming roughly ten years ago, discusses how the principles of functional programming - immutability, pure functions, and explicit side effects - make code easier to compose, test, and maintain. He argues that the main benefit of functional programming is efficiency in delivering value to the customer, and that the explicit nature of pure functions makes it straightforward to compose small functions into larger functionality while understanding their impact.

The conversation explores how functional programming principles become even more relevant in the age of AI coding agents. Barbini notes that agents work more efficiently and produce more consistent results on well-modularized, clearly defined codebases than on tangled ones, because agents rely on context and struggle with accidental complexity, complicated inheritance, and implicit conventions. He describes a multi-layered quality assurance approach inspired by the Swiss cheese security model, combining linters, mutation tests, agent-checking-agent reviews, and human oversight of pull requests.

Barbini also addresses the human and educational challenges of AI-assisted development. He warns that many developers fail to engage critically with AI output, and that junior developers risk missing the step-by-step learning process if they rely on AI without understanding the generated code. He advocates for using AI as a learning tool rather than a shortcut, and emphasizes that experienced developers who understand system design can multiply their productivity dramatically with agents, while those without that foundation often get sidetracked.

What If

  • What if you restructure your codebase into small pure functions before delegating work to AI agents?

    • Move: Refactor your most frequently modified modules so that each function takes explicit arguments and returns a single output, eliminating hidden state and singleton access. Wrap each module behind a clear interface with no inheritance hierarchy.
    • Why Now?: The source states agents are "much more efficient" and "produce better results, more consistently" on well-modularized code, and that complicated inheritance "is really not helping much." Preparing your code before scaling agent usage is a proposal that reduces rework.
    • Expected Upside: A possibility is fewer agent errors per task, less context sidetracking, and more consistent output quality, since agents can check what they can and cannot change without navigating implicit conventions.
  • What if you build a layered quality gate for every AI-generated pull request?

    • Move: Configure a pipeline where a linter runs first, then a mutation test suite on critical paths, then a second agent verifies requirement compliance, a third checks test coverage, and a fourth summarizes the PR for your review. Keep human review focused on abstraction decisions and edge-case judgment.
    • Why Now?: The source describes this as the "Swiss cheese model" where no single layer suffices, and notes that agents "tend to write too many tests to detail instead of concentrating on the important parts," making human review of test strategy essential.
    • Expected Upside: A proposal is catching overlapping failure modes that any single check would miss, while reducing your review time because agents handle mechanical verification and you concentrate on design judgment.
  • What if you use AI as a teaching partner rather than a code generator for your next feature?

    • Move: Before accepting any AI-generated code, ask the agent to produce a high-level test plan first, then ask it to explain each generated function line by line. Only proceed once you can articulate what the code does and why.
    • Why Now?: The source warns that people who "don't really engage with AI" end up "doing basically the wrong ticket to fix the wrong things," and that this is "much more common than people realize." The author's own practice of requesting tests before planning is cited as a guardrail.
    • Expected Upside: A possibility is catching misunderstandings early, building genuine understanding of the generated code, and avoiding the trap of shipping features that do not match the actual requirement.

Takeaway

  • Before delegating a feature to an AI agent, ask it to produce a high-level test plan first; use that plan to confirm mutual understanding of the requirement before any code is written.

  • Decompose your codebase into small pure functions with explicit inputs and outputs, removing singleton access and hidden side effects, so agents can reason about what to change without navigating implicit conventions.

  • Set up a multi-layer check on AI-generated code: run a linter, apply mutation testing on critical paths, have a second agent verify requirement compliance, and a third confirm test coverage, before you review the PR summary.

  • When reviewing AI-written tests, prune excessive edge-case tests and keep only those covering the happy path and important logic; concentrate your human judgment on abstraction decisions rather than mechanical coverage.

  • Use AI to explain generated code to yourself line by line before accepting it, treating the agent as a teaching partner rather than a black-box generator, so you retain the ability to debug and extend the code independently.

Recent Episodes of Podcasts by InfoQ

More Podcasts by InfoQ episodes

Do Functional Programming and Agents Play | Podcast Summarizer · fchf