Which Check Keeps the Lesson?¶
Run the Which Check Keeps the Lesson? MicroSim Fullscreen
This MicroSim belongs to Chapter 17: Rules That Enforce Themselves.
About This MicroSim¶
Every chapter of this book found gaps in the running example and named the fix. This MicroSim asks the next question: what is the cheapest check that would keep each fix from coming undone?
You see twelve lessons in a fixed order. Ten come from the running example, such as about 24 catch blocks that swallowed errors, model prices copied into ten files, one debt ID used twice, and a scheduler that used <= instead of =. Two are illustrative. For each lesson you pick one of six check types: formatter, linter rule, secret scan, CI check script, automated test (regression guard), or instruction file only.
The tally under the lesson fills in as you go. At the end it shows that only one of the twelve lessons had to stay in the instruction file. Every other lesson can be enforced by a program.
How to Use¶
- Read the lesson.
- Pick a check type with one of the six buttons, or click a column header in the tally.
- Press Check. If your first choice is wrong, you may pick once more.
- Press Next lesson. After lesson 12, press See summary.
- Hover over a lesson in the tally to read it and its explanation again.
Start over resets the activity.
Iframe Embed Code¶
You can add this MicroSim to any web page by adding this to your HTML:
<iframe src="https://arunbatchu.github.io/good-enough-engineering/sims/lesson-to-rule-sorter/main.html"
height="589px"
width="100%"
scrolling="no"></iframe>
Lesson Plan¶
Learning Objective¶
Recommend, for each of twelve lessons from the running example, the cheapest kind of automated check that would enforce it, or recognize that it can only be kept in the instruction file.
Grade Level¶
Adult professional (Good Enough Engineering)
Duration¶
10-15 minutes
Prerequisites¶
Automated check, automated test, regression guard, linter, formatter, pre-commit secret scan, CI pipeline, schema drift check, ID uniqueness check and project instruction file (Chapter 4 and Chapter 17).
Activities¶
- Exploration (2 min): Read the six check types and ask what each one looks at: code as text, running behavior, the schema, or a document.
- Guided Practice (8 min): Sort all twelve lessons. Before pressing Check, say what the check would need to look at.
- Assessment (5 min): Pick one lesson you got wrong first. Write the five lesson-to-rule steps for it: root cause, cheapest check, watch it fail, fix, commit both.
Common Misconceptions¶
- Every lesson needs a test.
- A line in the instruction file is as strong as a check.
- Some lessons are too small or too odd to enforce, such as a duplicate ID in a document.
Assessment¶
Mastery is 10 of 12 lessons correct on the first attempt. Lesson 6 accepts either a linter rule or a CI check script.
References¶
- ESLint: Custom rules - ESLint. How to write a lint rule for a project-specific pattern.
- Prettier: CLI and check mode - Prettier. Running the formatter with
--checkin CI. - Gitleaks - an open-source secret scanner for hooks and CI.
- GitHub Actions documentation - GitHub Docs. Where CI check scripts run.