How to forget my first pull request.
Considering how many websites were temporarily obliterated by the
left-padfiasco, being an npmjs maintainer might be an even higher power-to-effort ratio (by virtue of a near-zero denominator) than being a billionaire CEO.I still find it hilarious people think linking to some lib online on a live website makes sense. And people still do. Ehh.
I can imagine multiple scenarios where this could be useful. Simplest is perhaps the coder imagined at the time they could extend the function in later stages.
Then they could add their own function in later stages. YAGNI exists for a reason.
I think it is a balance. Despite having quite functional IDEs now a days, it is still more error prone to change 10 instances of math.random than a single function you define modularly. If you think there is a good chance such an extension might be needed in future or that you might want to change libraries later on, I wouldn’t necessarily call this a bad decision, even if it goes unused.
YAGNI works best when it prevents adding complex unused futures which are error prone and complicates a simpler program logic and flow. In this case you are just encapsulating a function inside another one without any change to program complexity.
It definitely depends on the use case. I could accept this being abstracted out to facilitate mocking, for instance (although I’d recommend mocking at a higher level). But in general this wouldn’t pass review with me unless I get a good explanation for why it’s necessary.
I get that this is a joke, but would something like
import Math.random as getRandomwork better? Because that basically what you’re doing here, renaming the function.If only there was a way to put ads in the code. Think of the revenue!
Simmer down, Satan
😂
Copilot - I see you’re using a random function, would you like to buy this cool shirt whose designer used Math.random() to help make them all unique?
deleted by creator
Currently having a new hire write a library in python and I noticed he was doing this in a few PRs. I went and explained to him this was not necessary and that he could just call the original function where he needed it. While showing him how to inline the functions I realised he was actually adding type annotations to functions which did not have them in the original libraries.
Nevermind what I told you, keep doing this.
Its a modernized version of Infinite monkey theorem but instead of typewriters and Shakespeare its importing libraries and Facebook.



