Curly’s law

Curly’s Law is a principle about choosing a single, clearly defined goal for any particular bit of code. It is a restatement of the single responsibility principle: a class or function should have one clearly defined purpose. The name comes from the "one thing" scene in the film City Slickers, in which the character Curly tells Mitch that the secret of life is "one thing."

The principle applies at every level of granularity. A function should do one thing, a class should serve one purpose, and a module should address one concern. When a unit of code accumulates several responsibilities, it becomes harder to reason about, harder to test, and harder to reuse. High cohesion and a single intent go hand in hand.

Curly’s Law is closely aligned with the broader tradition of clean code, where small focused units are preferred over large multi-purpose ones. Keeping each unit single-minded reduces the surface area for bugs and makes the code easier to change.

It is one of several design principles that favor locality of purpose. Rather than spreading one concern across many places, or folding many concerns into one place, the principle asks for a one-to-one mapping between a unit of code and the idea it expresses.