Invariants
Understand invariants and how they function to make the properties stronger and more reliable.
We'll cover the following...
What are invariants?
Some programs and functions are complex to describe and reason about. They might need many small parts to work correctly to be functional, or we may not be able to assert their quality because it’s difficult to define. For example, a judgment about whether a meal is good is subjective, although it could include criteria. The criteria could include whether the ingredients were cooked adequately, whether the food is served at the correct temperature, whether the meal is too salty, sweet, or bitter, etc. These factors play a part in the decision of “whether the food is good or not.”
Similarly, in a software system, we can identify similar conditions that should always remain true. These are called invariants.