Robustness Patterns

This chapter will cover several patterns that can be used to improve software robustness. By robustness, we are referring to the quality aspects, that is, can the software perform its functions correctly? Are all possible scenarios handled properly? This is an extremely important factor to consider when writing code for mission-critical systems.

Based on the Principle of Least Privilege (POLP), we would consider hiding unnecessary implementation details to the client of the interface. However, Julia's data structure is transparent – all fields are automatically exposed and accessible. This poses a potential problem because any improper usage or mutation can break the system. Additionally, by accessing the fields directly, the code becomes more tightly coupled with the underlying implementation of an object. So, what if a field name needs to be changed? What if a field needs to be replaced by another one? Therefore, there is a need to apply abstraction and decouple object implementation from its official interface. We should adopt the more general definition – not only do we want to cover as many lines of code as possible but also every possible scenario as well. An increase in code coverage would give us more confidence about the correctness of our code.

We have classified these techniques into the following sections:

  • Accessor patterns
  • Property patterns
  • Let block patterns
  • Exception handling patterns

By the end of this chapter, you will be able to encapsulate data access by developing your own accessor functions and property functions. You will also be able to hide away global variables from unexpected access outside of the module. Finally, you will also know about various exception handling techniques and understand how to retry failed operations.

Let's get started!

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

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