Application business rules live in explicit use cases

clean-arch-002

Intent

Workflow rules belong in an owning use case, interactor, or application-service boundary, not in controllers, repositories, views, or framework hooks.

Applicability

Applies when the diff changes business behavior in a repo with visible use cases, handlers, or equivalent workflow boundaries.

What to inspect

Changed handlers, controllers, services, repositories, callbacks, and where business sequencing or decisions now live.

Pass criteria

Business workflow remains concentrated in an explicit use-case boundary and outer adapters stay thin.

Fail criteria

The diff spreads substantial business workflow across controllers, mailers, repositories, views, or other outer adapters.

Do not flag

Thin routing, parsing, authorization, formatting, and persistence-only code.

Confidence guidance

HIGH when the outer adapter clearly owns business sequencing. MEDIUM when ownership is inferred from names and surrounding code. LOW when no stable use-case layer is visible.

Remediation

Move the changed workflow into an existing use case, or extract the smallest owning use case needed for this behavior, and keep outer layers focused on translation and I/O.

Pass example

final class TransferFunds {
    void handle(Command cmd) { account.debit(cmd.amount()); }
}

Fail example

@RestController
final class TransferController {
    void post(Request req) { if (balance < req.amount()) throw ...; repo.save(...); }
}

Sources

  • A Philosophy of Software Design — John Ousterhout book
  • Vertical Slice Architecture isn't technical — Derek Comartin article
  • Get Your Hands Dirty on Clean Architecture — Tom Hombergs book
  • Hexagonal Architecture — Alistair Cockburn article
  • Sustainable Web Development with Ruby on Rails book