AR8: Engineering standards and code review

Lesson 1 of 5 · reading 15–25 minutes; practice and project time is on the module page

Standards worth having

🎯You'll be able to

Write a short set of coding standards in which each rule has a reason, an example and a way it's checked.

🏠The everyday picture

A busy kitchen has a few firm rules: label and date everything in the fridge, wash hands after raw meat, call "behind" when passing. Each prevents a real problem. Nobody needs fifty rules about how to hold a spoon.

📘What it really is

📝A worked example

Input: the starter's standards: "Write clean code. Use good names. Test your code. Don't commit secrets."

Steps:

  1. "Don't commit secrets" becomes R1: No secrets in code. Why: anyone who can read the repository can use them. Checked by: lint no-secrets. Example: process.env.PAYMENTS_API_KEY.
  2. "Write clean code" is too vague; replace with specific rules, such as R3 (errors handled, not hidden) and R5 (functions under 40 lines).
  3. "Use good names" becomes R2 with an example, checked by review.
  4. Add "Version: 1.0" and "Last reviewed".

Expected output: a document of eight to twelve rules, each with why, an example and how it's checked.

🌍Where it's used

📝Case scenario

A team's 40-page style guide covered brace positions and blank lines, and said nothing about secrets. Nobody read it. A key was committed and abused within hours. A one-page set of ten rules, starting with secrets and error handling, became the guide people actually used.

🖱️Try it

Turn two vague rules from any guide you know ("be clean", "be safe") into specific rules with a reason, an example and how they're checked. Success: someone could tell whether code follows them.

⚠️Common mistakes

🛠️For your project

Project 3's test 1 checks at least eight rules in docs/standards.md, each with Why, Checked by and a code example.

✅Quick check

What should every rule in a standards document include?

Show the answer

An ID, the rule, why it exists, an example and how it's checked.

Why should style questions be settled by a formatter rather than by review?

Show the answer

They're preferences, and a tool settles them without arguments, leaving review for what matters.

← BackAR8
ProLearners Assist