Design Patterns · Junior · Question 49 of 75
Why are pure functions useful in design?
- ✓Correct answer: The result depends only on the arguments - they're easy to test
- 2They run faster because the engine caches their results
- 3They can't contain conditionals or loops
Explanation
A pure function without side effects is predictable: the same input gives the same output. It pays to move business logic (price calculation, validation) into pure functions and keep side effects at the edges of the system.