🧼 Web Dev

Clean Code for Beginners — 7 Naming and Function Rules

📅 Jul 2, 2026 ⏱ 4 min read

Interviewers read your project code. Reviewers judge your PRs. These seven rules are most of what "clean" means.

The rules with receipts

1. Names say what, honestly:

// ❌ const d = new Date(); function proc(x) {}
// ✅ const enrollmentDate = new Date(); function calculateGpa(marks) {}

2. Booleans read as questions: isEligible, hasArrears, canSubmit.

3. Early return beats nesting:

// ❌ if (user) { if (user.active) { if (!user.banned) { ... } } }
// ✅
if (!user?.active || user.banned) return;
// happy path continues un-indented

4. No magic numbers: if (cgpa >= MIN_PLACEMENT_CGPA) not >= 6.5.

5. Functions do one thing — if the name needs "And", split it.

6. Delete dead code — git remembers; comments-as-graveyard confuse readers.

7. Comments explain WHY, never what: // AU rounds credits down per R2021 reg 4.2 is gold; // loop over array is noise.

Consistency beats cleverness — code is read 10x more than written.

← All Articles