3 ms·
One would argue that both are flawed because they are, in essence, a function which is not espressing itself clearly and cleanly. You are co-mingling state with
by wheaties 13y ago
One would argue that both are flawed because they are, in essence, a function which is not espressing itself clearly and cleanly. You are co-mingling state with computation in a way that obscures and loses the advantages therein.
If you want to make an example of something, then use a Reader, such that you are abstracting away the "source" of what is read and the side-effects thereof. Or an expiring cache (which is a good example of mutable state.) Or a mixed Reader which "reads" from either a cache or in the case of passing the expiration mark on the "key," some unknown "source."
- adwn 13y agoIt's an example, sheesh! I suspect you're a programmer, so you should be able to abstract away the details of the example and take home the message.