Concept

Composition

Definition

Composition is the discipline of building larger systems by connecting smaller parts that each do one well-defined thing. The parts have narrow interfaces — they declare what they take in, what they emit, and nothing else — which means they can be rearranged, replaced, or reused without rewriting the system around them. The whole is exactly the sum of its parts wired together; there is no hidden glue.

The clearest expression is the Unix pipe: a chain of small programs joined by the | operator, each reading text from standard input and writing text to standard output. The same principle generalises to function composition in mathematics and programming, to service composition in distributed systems, and to component composition in user interfaces.

Why it matters

How it works

The mechanics differ across domains but the shape is identical. In a Unix pipeline, each process inherits a file descriptor from the previous process and writes to one used by the next; the operating system handles buffering, scheduling, and back-pressure. In functional programming, a composed function f . g is a new function whose input is g's input and whose output is f's output of g's output. In a microservice architecture, services compose through HTTP or message queues, each accepting a request shape and emitting a response shape its callers can rely on.

The shared discipline is interface narrowness. A composable component must not leak its internals — no hidden state, no implicit ordering requirements, no surprise side effects. The Unix tool sort does one job and never asks where its input came from; a pure function does not care what called it; a well-designed service does not assume a particular client. That narrowness is what lets the same part appear in pipelines its author never imagined, which is the whole point.

Where it goes next

Continue exploring

Tags