• rtxn@lemmy.world
    link
    fedilink
    arrow-up
    60
    ·
    edit-2
    24 days ago

    Considering how many websites were temporarily obliterated by the left-pad fiasco, 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.

    • magikmw@piefed.social
      link
      fedilink
      English
      arrow-up
      2
      ·
      23 days ago

      I still find it hilarious people think linking to some lib online on a live website makes sense. And people still do. Ehh.

  • Avicenna@programming.dev
    link
    fedilink
    arrow-up
    18
    ·
    24 days ago

    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.

      • Avicenna@programming.dev
        link
        fedilink
        arrow-up
        9
        ·
        edit-2
        24 days ago

        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.

        • Jesus_666@lemmy.world
          link
          fedilink
          arrow-up
          5
          ·
          24 days ago

          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.

  • abbadon420@sh.itjust.works
    link
    fedilink
    arrow-up
    12
    ·
    edit-2
    24 days ago

    I get that this is a joke, but would something like import Math.random as getRandom work better? Because that basically what you’re doing here, renaming the function.

  • ranzispa@mander.xyz
    link
    fedilink
    arrow-up
    4
    ·
    22 days ago

    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.