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 on the Mocking package for a more seamless approach. We then learned how to replace function calls with stubs and mocks in our test suite and how they work differently.

Finally, we learned about the functional pipes pattern and how it can make the code easier to read and follow. We learned about composability and how the compose operator works similarly to the pipe operator. We went over how to develop efficient code using functional pipes and broadcasting. Finally, we discussed the pros and cons of using functional pipes and other related considerations.

In the next chapter, we will turn around and look at some anti-patterns of Julia programming.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.122.4