Multiple ChoiceIntermediate 45s
Tell, Don't Ask vs getters
A service reads ten getters off an Order, computes a total, and saves it back. Which refactor better respects encapsulation and SRP?
Options
- 1Add more getters so the service can stay the single place computing totals
- 2Move the total computation into Order as a behavior and ask the object for the result
- 3Make all Order fields public to avoid getter overhead
- 4Cache the total in a global map keyed by order id
Think you can answer under pressure?
Get matched and answer live questions in 3-minute 1v1 battles. Elo ranking, badge tiers and bragging rights on the line.