November 2017
Intermediate to advanced
670 pages
17h 35m
English
Identifying when using monoid can help us make design decisions that affect performance.
On day one, we're asked to add 1 + 2 + 3. Then, on day two, we're asked to add 1 more. We don't have to add 1 + 2 + 3 again. We can simply store that and add our new 1 to it: 6 + 1 = 7.
Given that nothing is free, what did it cost us to gain the performance boost of not having to add 1 + 2 + 3? Storage. The question becomes, which is more costly? The answer to that will tell us whether to leverage referential transparency or not. Just because we can do something does not mean we always should.