Back

Code comments

Good code explains what it does through clear names. Comments should explain why: a business rule, a workaround, or something surprising. Delete commented-out code. Git already remembers it.

// Bad: repeats the code
// add 1 to count
count = count + 1

// Good: explains why
// Stripe charges in cents, so convert dollars before sending
const amount = price * 100

// Good: warns about something non-obvious
// API returns dates in UTC; convert before showing to the user
const localDate = new Date(order.createdAt).toLocaleString()

Roadmap