2 ms·
> This maintains the invariant without state. Yes, but this is not possible in general. For instance, what if you want to endow your List with a "MaxTotalCost"
by zozbot234 6y ago
> This maintains the invariant without state.
Yes, but this is not possible in general. For instance, what if you want to endow your List with a "MaxTotalCost", set at creation. You can't ensure that your list respects that invariant, other than by encapsulating it behind some custom interface.
- joshuamorton 6y agoThat's true, although it raises a question: is the maximum you're willing to spend a trait of your bill of materials (I'd argue no), or of some other thing, for example your overall project. In that case you could have a method that validates your BOM against your project requirements.