![]() |
|
No such thing as a small change | |
PerlMonks |
Re^3: use Memoize;by sundialsvc4 (Abbot) |
on Jul 18, 2018 at 20:45 UTC ( #1218785=note: print w/replies, xml ) | Need Help?? |
I don’t think that we need to review how Memoize necessarily must do what it does. It is, indeed, perfectly obvious that it must consider the entire parameter-list to form its cache-key in order to return the correct result. Therefore, it is nonsensical to suggest that I somehow didn’t grok that. My concern is very specific – that Memoize is a too-clever-by-half approach that might well break(!) a program, and do so in a way that you do not initially detect. There are precious few “pure functions” in the real-world of computer programming, so you might very easily use this tool, rejoice that “now it runs so much faster!,” and simply not realize that you have not only fundamentally changed the behavior of the program, but have done so in a way that is dependent upon the input data! Most importantly, the source-code no longer accurately reflects what the program will do: its behavior is now literally dependent upon the sequence in which parameter-lists have been presented to this function. It is difficult if not impossible to test this. Knowing, therefore, that in the real world functions are usually not “pure,” I would instead resort to “more pedantic” logic that is objectively testable. ... and I will be the very first to state that this is my opinion, and nothing more. However, this opinion is borne from the experience of constantly working with very-big, very-old legacy systems that cannot be understood in their entirety by anyone who is working on them now. Viewed from this perspective, anything “far away from here and therefore very-easily overlooked,” which might cause the behavior of the system to deviate from “what the source code says,” is pretty-much a disaster. To the point that, yes, one of my “initial assessment tasks” is to look for Memoize, re-engineer all of the cases that might be found, and create tests. That’s my point-of-view on this, and it is legitimate.
In Section
Meditations
|
|