Test your Clean Code knowledge with a free interactive quiz — 28 questions with answers and explanations. No signup needed to play.
Question 1/5Score 0
Why is a boolean "flag parameter" (e.g. `save(user, true)`) considered a code smell?
Questions in this quiz
Why is a boolean "flag parameter" (e.g. `save(user, true)`) considered a code smell?
A `checkout(cart, user)` function validates the cart, computes tax, saves the order, and sends a confirmation email -- all in one function body. What clean-code principle does this violate?
A catch block re-throws with `throw new Error('Failed to save user ' + user.id, { cause: err })`. What is the purpose of preserving `err` as `cause`?
Treating error handling as a first-class concern rather than an afterthought means:
A function `calculateTotal(cart)` is extracted out of a larger `checkout()` function so it can be unit tested independently. What is the primary clean-code benefit of this extraction?
What is a "code smell" in clean-code terminology?
Compare two ways of writing input validation for `title` and `body` fields, duplicated identically inside both `createPost(data)` and `updatePost(data)`, versus extracting it into a shared `validatePost(data)` called by both. Which is the clean-code choice and why?
A block of code has a comment reading `// check if user can edit (admin or owner)` directly above a function named `chk(u, r)`. What is the clean-code critique?
A function has 7 parameters, several of them optional booleans controlling different behavior branches inside it. What does clean-code guidance suggest?
What is a key risk of comments that clean-code guidance warns about?
What is wrong with encoding a variable's type into its name, e.g. `usersArray` or `nameStr`?
A teammate needs a comment to explain what a function named `chk(u, r)` does. What is the clean-code fix?