Translate Java design intent into Clojure shapes: immutable data, pure functions, explicit effects, higher-order functions, and boundaries instead of one-to-one class ports.
Migration succeeds when you translate intent, not syntax. The functional equivalent of a Java design is usually not a new set of classes; it is a data model plus a set of pure functions that transform it.
This section builds a mapping between familiar Java moves (mutable accumulators, strategy objects, builders) and idiomatic Clojure moves (pipelines, higher-order functions, maps/vectors). The goal is to keep side effects at the edge so the core remains easy to test.
| Java habit | Functional Clojure equivalent |
|---|---|
| Mutable accumulator loop | reduce, into, transducers, or a named step function over immutable values. |
| Strategy object | A function argument, multimethod, protocol, or map of handlers depending on extension needs. |
| Builder object | A data construction pipeline with validation at the boundary. |
| Service method with side effects | A pure core function plus an adapter that performs I/O, time, logging, or Java interop. |