Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Document preview thumbnail
Preview 2 out of 10 pages
Exam (elaborations)

Clean Code Set 1 Questions and Answers

Document preview thumbnail
Preview 2 out of 10 pages

Clean Code Set 1 Questions and Answers

Content preview

Clean Code | Set 1 Questions and Answers with 100% Correct
Answers | Latest Version

Question 1.
What are the guides to good naming?

Correct Answer: 1. Use intention-revealing names
2. Avoid disinformation
3. Make meaningful distinction
4. Use pronounceable names
5. Use searchable names
6. Avoid encodings
7. Avoid mental mapping
8. Pick one word for a concept, and stick with it
9. Avoid have one-word concept mean more than one thing
10. Use solution-domain names (CS terms)
11. Use problem-domain names for non-programmers
12. Add meaningful contexts


Question 2.
What does it mean to be intention-revealing?

Correct Answer: Allow naming of variables/classes/methods to answer the
question the code-reader will have when going through the logic


Question 3.
Give an example of being misleading in naming

Correct Answer: If you have in general, a group of accounts, and name it:
"accountList" This can be misleading because it can apply that this is
List<Account>, when the variable could be not a List type at all. It is better to
name it as: "groupOfAccounts" "accounts"


Question 4.
What does it mean to have names that have meaningful distinctions

Correct Answer: When you write code to solely satisfy the compiler ex) a1, a2..
aN You want to make distinct calls and avoid making similar names to confuse
the reader. Sometimes you need to reduce your abstractions or distinctively
name them.


Question 5.
What does it mean to avoid mental mapping?

Correct Answer: Reader shouldn't have to cache in his/her head the abstractly
named variable throughout reading the logic. Avoid making the reader think:
"what was this {BAD_VARIABLE_NAME} again? "

, Question 6.
What does it mean to have "good" context?

Correct Answer: "state" Does this mean it will have values like "GA", "IL", "NY"
OR does this mean the state of the application? Give more context to ambiguous
names. Also, don't add too much context.


Question 7.
What are guides for good functions?

Correct Answer: 1. Smaller lines (Indent level should not exceed 1-2)
2. Do one thing
3. One level of abstractions per function
4. Use descriptive names (don't be afraid to name things long)
5. Should avoid having more than 2 arguments
6. It's okay to convert multiple arguments to one argument object
7. Variable argument are considered as one argument
8. Make your function names have a verb and keywords that give clear context
9. Have no side effects
10. If your function must change the state of something, have it change the
state of its owning project


Question 8.
What does it mean to have a function do one thing?

Correct Answer: If a function does only the steps that are one level below the
stated name of the function, then the function is only doing one thing


Question 9.
We want to be able to read the program as though it were a set of steps, each of which is
describing the current level of abstraction and referencing subsequent steps at the next
level down.

Correct Answer: The step down rule


Question 10.
Single Responsibility Principle

Correct Answer: a class/method should have only a single responsibility (i.e.
only one potential change in the software's specification should be able to affect
the specification of the class)


Question 11.
Open/Closed Principle

Correct Answer: Classes should be open for extension but closed for
modification.

Document information

Uploaded on
September 8, 2026
Number of pages
10
Written in
2026/2027
Type
Exam (elaborations)
Contains
Questions & answers
$15.99

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
Favorgrades
3.8
(193)
Sold
830
Followers
376
Items
53697
Last sold
1 hour ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions