Data Invariants
First of all, that Interval type is insane. The Max of the interval [7, ∞) is 7!? What!? And (-∞, 7] and [7, ∞) are both OK but (-∞, ∞) isn&#x27;t? As software engineers, it&#x27;s our job to spot that whatever requirement is driving this type is <i>absolute nonsense</i> and we need to refuse to implement such a stupid data type and work back up the chain until whatever stupidity led to this situation is resolved. I would literally refuse to write this code, and so should you. This is the difference between a &quot;programmer&quot; and a &quot;software engineer&quot;. A programmer says &quot;yup, sure, interval, got it&quot;, and a software engineer says &quot;hell no, that&#x27;s insane, something is very wrong.&quot;<p>Secondly, you&#x27;re <i>mutating</i> an <i>interval</i>!? Holy moly mother of god that gives me nightmares. There are a few data structures where mutation makes sense, where they&#x27;re used privately as part of an algorithm and then thrown away or frozen. Other than that, there is absolutely no excuse whatsoever to make data types mutable. There are <i>no</i> reasonable arguments to made for making an interval like this mutable; any argument you give me could be extended to making an int mutable, which is absolute crazy nonsense.<p>Seriously, this code is absolutely terrifying. &quot;Data Invariants&quot; as described here sounds like someone talking about techniques for setting up guardrails along the road because they constantly drive off of it. It sounds like maybe you need to go back to driving school instead of worrying about how to build better guardrails.