Test it. Break it. Understand it.
Module 5 / Lesson 3

Pure logic, messy boundaries

Keep deterministic decisions separate from clocks, networks and storage.

17 minutes

A pure core is easy to reason about

A function that receives session records and a selected date can return matching records without reading the current time or making a network request. The same inputs produce the same result.

Put uncertainty at the edges

Network calls, timezone conversion and database writes belong at explicit boundaries. This lets you test the rule with fixed inputs and test each integration separately. The extra structure earns its place when it isolates a real source of uncertainty.

javascript
function sessionsOnDate(sessions, date) {
  return sessions.filter(session => session.date === date);
}
const demo = [{ id: "S1", date: "2026-10-15" }];
console.assert(sessionsOnDate(demo, "2026-10-15").length === 1);
console.assert(sessionsOnDate(demo, "2026-10-16").length === 0);