What is clean code, and how should you name things, write functions and use comments?
Short answer
Clean code is code others can read and change safely, fast. Code is read far more than written, so the core habits are intention-revealing names, functions that do one thing, guard clauses and comments that say why.
3 points to say:
- Clean code = easy to read and change safely, fast; maintenance is the main cost.
- Business names with units (
timeoutMs), booleans read as questions; guard clauses keep the happy path flat. - A function is a command or a query, not both; comments explain why, not what the code already says.
Keep reading the deep dive
Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.