Avoid with-redefs in tests

Advice to avoid with-redefs often focuses on the wrong things. It is true that with-redefs can cause race conditions in your test suite. And that functions can be captured in closures, leading to them not being redefined as one might expect. And that with-redefs doesn’t redefine inlined functions. And that with-redefs can cause problems with type-hinted functions. And that they cause problems when used with macros. And that mutating the global environment is something functional programmers should know is a bad practice. Etc., etc. ...

2025-04-07 · 3 min · 591 words · Thomas Cothran

Top-Down Imperative Clojure Architectures

When I first became interested in functional programming, a more experienced engineer told me: “you know functional programming doesn’t really amount to much more than procedural programming.” As I insisted on the benefits of map, filter and reduce, he simply shook his head. “You’re thinking in the small. Go look at a large real-world application.” It took some time for me to see what he meant. My preferred language, Clojure, is a functional language. But too often it is used to build top-down, imperative applications. This negates the value proposition of functional programming: isolating side effects, local reasoning, and system composition. ...

2024-07-22 · 7 min · 1280 words · Thomas Cothran

Brittle Clojure: Creating Legacy Clojure Systems

This is the first in a multi-part series, “Brittle Clojure”. In this series, we will consider common patterns in Clojure which yield brittle systems, as well as methods to ensure robustness. None of the basic principles for building robust software are unique. Most literature, however, is focused on object-oriented systems. Our point of view will sometimes zoom in to Clojure “in the small”, and sometimes zoom out to distributed systems built with Clojure. ...

2023-07-23 · 11 min · 2187 words · Thomas Cothran