• Windex007@lemmy.world
    link
    fedilink
    arrow-up
    8
    ·
    7 days ago

    When you start to bump into any of these concerns, I’d recommending extracting the functions themselves, rather than breaking the pipeline… which was not something mentioned or explored.

    • bitcrafter@programming.dev
      link
      fedilink
      arrow-up
      6
      ·
      7 days ago

      One can definitely go overboard with this, though. I have had to read a lot of code where someone broke something up into several functions that only had the effective of forcing me to constantly bounce around all over source file to figure out what was going on without improving clarity at all.

      • clif@lemmy.world
        link
        fedilink
        arrow-up
        5
        ·
        7 days ago

        Ugh, SonarQube with the cognitive complexity check.

        “Instead of having 50 lines where all logic is right here, I’mma need you to break it up into 10 separate functions so it’s a massive pain in the ass to figure out what the fuck is going on”

        I understand the reasoning but sometimes it’s way more confusing to split up complex logic instead of just having it all in one place.

  • Dumhuvud@programming.dev
    link
    fedilink
    English
    arrow-up
    6
    ·
    edit-2
    7 days ago

    Only tangentially related, but I dislike that filter and map are eager in JS. Meaning if you chain them, you allocate N-1 arrays that are being discarded right away. C#, Java and Rust have the right approach.

  • bitcrafter@programming.dev
    link
    fedilink
    arrow-up
    3
    arrow-down
    1
    ·
    7 days ago

    Ugh, I absolutely hate reading code with a ton of variables that are only used once, because each introduction of a variable is a new thing that I have to first parse and then track to figure out what it does. I would much rather read a pipeline that expresses what is going on concisely without introducing extraneous elements. In particular, I thought that the pipeline at the start of the article was perfectly clear and did not need any of the subsequent modifications.

    • bitjunkie@lemmy.world
      link
      fedilink
      arrow-up
      1
      ·
      5 days ago

      Throwaway variables are an antipattern. Say what you will about Airbnb as a company, but their JS style guide is fucking dead on.