Summary
In this chapter, we learned about several patterns that can be quite useful in application design.
We started with the singleton type dispatch pattern. Using a command processor example, we successfully refactored the code from using if-then-else conditional statements to utilizing dynamic dispatch. We learned how to create new singleton types using the standard Val type or rolling our own parametric type.
Then, we switched gears and discussed how to implement automated testing effectively using the stubbing/mocking pattern. We took a simple use case of a credit approval process and experimented with a simple way to inject stubs using keyword arguments. We weren't very satisfied with the need to change the API for testing, so we leaned ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access