Question 8
Back to Exercise
What does the "tell, don't ask" principle recommend?
- A Never write getters
- B Tell objects what to do (account.withdraw(500)) instead of asking for their data and deciding outside (if (a.balance() >= 500) a.set_balance(…)) Correct
- C Use exceptions instead of return values
- D Prefer global functions
Correct Answer: Option B
The decision then lives next to the data it depends on, in one place.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!