Summary

In this chapter, we have explored several patterns related to reusability. These patterns are highly valuable and can be utilized in many places within an application. In addition, people coming from an object-oriented background will probably find this chapter indispensable when it comes to designing Julia applications.

First, we went into great detail about the delegation pattern, which can be used to create new capabilities and lets us reuse functions from an existing object. The general technique involves defining a new data type that contains a parent object. Then, forwarding functions are defined so that we can reuse the functionalities of the parent object. We learned implementing delegation can be largely simplified by using @forward, which is provided by the Lazy.jl package.

Then, we examined the holy trait pattern, which is a formal way to define the behavior of objects. The idea is to define traits as native types and utilize Julia's built-in dispatch mechanism to call the right method implementation. We realize that traits are useful in making the code more extensible. We also learned that macros from the SimpleTraits.jl package can make trait coding easier.

Finally, we looked into the parametric types pattern and how it can be utilized to simplify the design of code. We learned that parametric types can reduce the size of our code. We also saw that parameters can be used in the bodies of parametric functions.

In the next chapter, we will discuss an important subject that attracts a lot of people to the Julia programming language performance patterns!

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

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