11

Split Phase


Goal

Each phase reads and writes its own well-defined inputs and outputs; the seam between them is data, not control flow.

Before the refactoring
function priceAndRender(input) {
  const price = computePrice(input);
  return renderHTML(input, price);
}
After the refactoring
function pricing(input) { return { ...input, price: computePrice(input) }; }
function render(priced)  { return renderHTML(priced); }
Savings

Phases evolve independently; tests target each phase in isolation; the intermediate shape becomes a documented contract.

Note

An intermediate data structure between the phases is overhead — earn it by separating two clearly different concerns.