• Eager Eagle@lemmy.world
    link
    fedilink
    English
    arrow-up
    2
    ·
    14 hours ago

    it’s turtles all the way regardless; but it’s much easier to handle side effects if you have more numerous but smaller functions.

    I prefer that because fully reading a module or component is not the most common scenario. The most common use case of reading code is (or should be) not caring about most of the implementation details until you need to; only then you have to go down the rabbit hole.

    Longer functions force the reader to understand most of their context every time they get there, a problem especially when the function has a bunch of local vars.

    • bitcrafter
      link
      fedilink
      arrow-up
      1
      ·
      11 hours ago

      I agree completely that, when done well, smaller functions can make code easier to work with for all of the reasons that you have mentioned. When not done well, however, I still have to read through all of the same code to figure out which part has the implementation detail that I need to care about, but now it has been scattered about instead of collected into one convenience place.