Terminology (5)Terms used in this lesson
Term on the front, definition on the back. Paste with tabs between fields and a new line between cards, or import the download in Anki as Basic.
- Observation
- What the supplied run or tool actually displayed under its stated source, input and profile.
- Justified conclusion
- A claim supported by the observed facts and the applicable language/library contract.
- Summary collision
- Different detailed data producing the same selected aggregates.
- Measurement effect
- A change made to the subject while collecting an observation, which can alter later evidence.
- Explanatory model
- An explicitly scoped account of selected relationships; omitted facts are not established by the model.
Observations and the models they support
A mental model predicts what a program will do. An observation supplies evidence for that prediction under a particular source, input and execution configuration. Printed output is itself a selected view of state: a preview can show a few entries, and a summary can combine many entries into one number.
Choose an observation that can distinguish the possibilities relevant to the claim. A collection’s size, membership and values answer different questions. Also inspect the operation used to collect evidence: an apparent lookup can have effects of its own. Record what the measurement covers and whether it preserves the data needed for the next comparison.
01Observation scope
Does the short preview mean the import lost a label?
A document-label service is importing its catalog into a replacement store. The review must preserve every registered label and its document count, including labels with no documents. The import report shows a two-label preview and a compact match claim. Decide what that report can establish before approving the import.
The source export lists three registered labels: oak, elm and ash. The import report prints two names to keep its preview short, then a separate collection count. Use input 3 oak elm ash. Before reporting a missing label, predict the complete count.
import { readFileSync } from "node:fs";
const tokens = readFileSync(0, "utf8").trim().split(/\s+/);
let at = 0;
function readCounts(): Map<string, number> {
const size = Number(tokens[at++]);
const result = new Map<string, number>();
for (let i = 0; i < size; i++) {
const key = tokens[at++];
result.set(key, Number(tokens[at++]));
}
return result;
}
function total(counts: Map<string, number>): number {
let sum = 0;
for (const value of counts.values()) sum += value;
return sum;
}
const size = Number(tokens[at++]);
const labels = tokens.slice(at, at + size);
console.log("preview", labels[0], labels[1]);
console.log("count", labels.length);
npx tsc main.ts --noEmit --skipLibCheck --target es2022 --module nodenext --types node && node main.ts
Standard input (escaped): "3 oak elm ash\n"
02Discriminating evidence
What did the report actually compare?
The count is plausible, so the review turns to document counts under each label. In this reduced comparison, left is the source catalog and right is the imported catalog. Each input gives an entry count followed by unique label/count pairs. The report calls them a match when size and total agree. Predict whether that claim meets the import requirement for red 3, blue 1 versus red 2, blue 2.
import { readFileSync } from "node:fs";
const tokens = readFileSync(0, "utf8").trim().split(/\s+/);
let at = 0;
function readCounts(): Map<string, number> {
const size = Number(tokens[at++]);
const result = new Map<string, number>();
for (let i = 0; i < size; i++) {
const key = tokens[at++];
result.set(key, Number(tokens[at++]));
}
return result;
}
function total(counts: Map<string, number>): number {
let sum = 0;
for (const value of counts.values()) sum += value;
return sum;
}
const left = readCounts();
const right = readCounts();
const leftTotal = total(left);
const rightTotal = total(right);
console.log("summary", left.size, leftTotal, right.size, rightTotal);
console.log(
"claim",
left.size === right.size && leftTotal === rightTotal ? "match" : "different",
);
npx tsc main.ts --noEmit --skipLibCheck --target es2022 --module nodenext --types node && node main.ts
Standard input (escaped): "2 red 3 blue 1 2 red 2 blue 2\n"
03Measurement effects
Can the review probe change the imported catalog?
The importer must also retain registered labels with zero documents. The next source catalog is red 2, zeta 0; the import is red 2, blue 0. Their summaries collide again. The diagnostic now looks up zeta in the imported catalog and prints its size. Predict that final size before treating the lookup result as membership evidence.
import { readFileSync } from "node:fs";
const tokens = readFileSync(0, "utf8").trim().split(/\s+/);
let at = 0;
function readCounts(): Map<string, number> {
const size = Number(tokens[at++]);
const result = new Map<string, number>();
for (let i = 0; i < size; i++) {
const key = tokens[at++];
result.set(key, Number(tokens[at++]));
}
return result;
}
function total(counts: Map<string, number>): number {
let sum = 0;
for (const value of counts.values()) sum += value;
return sum;
}
const left = readCounts();
const right = readCounts();
const leftTotal = total(left);
const rightTotal = total(right);
console.log("summary", left.size, leftTotal, right.size, rightTotal);
console.log(
"claim",
left.size === right.size && leftTotal === rightTotal ? "match" : "different",
);
const inspected = right.get("zeta");
console.log("lookup", inspected);
console.log("right-size", right.size);
npx tsc main.ts --noEmit --skipLibCheck --target es2022 --module nodenext --types node && node main.ts
Standard input (escaped): "2 red 2 zeta 0 2 red 2 blue 0\n"
Try one change
In a local copy of the import comparison, make the reported match depend on the required per-label facts while preserving both original catalogs during inspection. Run inputs with equal summaries and different details, including a present zero and an absent label. State which observations establish the corrected claim. The decision checker does not certify this local edit.
Check this idea later
04Practice
Review the next catalog import
Review a second import report. Compare two previews, test a proposed one-label check, then follow repeated inspection of the same imported object. The Source tab retains the complete native programs. The new ticket reports are authored expectations for their displayed inputs; Check work grades your decisions and does not execute a program.
The lab opens in your primary reading language. Its source is immutable evidence; your recorded decisions are the assessed work. Input parsing and complete native callers are supplied.
Check the import report
Compare previews, test a proposed check and preserve the evidence for a full comparison.
Sources
TypeScript
Sign in to keep your read marks on every device. Sign in
Was this helpful?