Field study 005 / Testing & simulation
The time machine
Rewind a customer account to investigate how its state changed.
FIG. 05 / Account timeline SK / ENGINEERING STUDIES
MYJAR / TxtLoan · 2011–2013 · Lead developer on the backend rewrite · Tallinn Field notes
The time machine let account managers move through a customer’s loan history. It also made repayment schedules testable without waiting for real time to pass.
Our backend rewrite included over 2,000 unit and integration tests. The demo below uses an illustrative schedule to show the idea.
Visit the archived 2012 homepage ↗View React component source
import { useEffect, useState } from "react";
export default function Demo({ timeline = false }: { timeline?: boolean }) {
const [live, setLive] = useState(false),
[day, setDay] = useState(0);
// Keep server-rendered controls inert until React has attached its handlers.
const [ready, setReady] = useState(false);
useEffect(() => setReady(true), []);
return (
<fieldset className="demo-frame" disabled={!ready}>
{content()}
</fieldset>
);
function content() {
if (timeline)
return (
<section className="demo">
<small>INTERACTIVE STUDY / SAMPLE ACCOUNT</small>
<h2>Move through time</h2>
<label htmlFor="day">Day {day} of 30</label>
<input
id="day"
type="range"
min="0"
max="30"
value={day}
onChange={(e) => setDay(Number(e.target.value))}
/>
<p aria-live="polite">
{day < 15
? "Loan issued · Balance £100"
: day < 30
? "First repayment · Balance £50"
: "Account settled · Balance £0"}
</p>
</section>
);
return (
<section className="demo">
<small>INTERACTIVE STUDY / LOCAL SIMULATION</small>
<h2>A branch of its own</h2>
<p>
Push a feature branch to provision its environment. Delete it to
release the resources.
</p>
<button
className="button"
aria-pressed={live}
onClick={() => setLive(!live)}
>
{live ? "Delete branch" : "Create branch"} ↗
</button>
<div className="resources" aria-live="polite">
{["API service", "Database", "Subdomain"].map((r, i) => (
<div key={r}>
<b>{r}</b>
<code>
{live
? [
"feature-42/api",
"db_feature_42",
"feature-42.example.test",
][i]
: "Not provisioned"}
</code>
</div>
))}
</div>
</section>
);
}
}
Next field study From browser to television →