• TanakaAsuka@sh.itjust.works
    link
    fedilink
    arrow-up
    27
    ·
    1 year ago

    I mostly agree with this but more than shorter code I value readability, I would rather take 3 lines to be clear to any developer than use some obscure or easy to misunderstand structure to write it in 1.

      • Feathercrown@lemmy.world
        link
        fedilink
        English
        arrow-up
        6
        ·
        1 year ago

        I think it really depends. Functions break up the visual flow, so if you need to look at multiple functions to visualize one conceptual process then it can be less efficient

        • Buttons@programming.dev
          link
          fedilink
          English
          arrow-up
          4
          ·
          1 year ago

          Yes. I learned this from Haskell. I like Haskell, but it has a lot of very granular functions.

          Earlier comment said that breaking up 1 function into 3 improves readability? Well, if you really want readability then break it up into 30 functions using Haskell. Your single function with 25 lines will become 30 functions, so readable (/s).

          In truth, there’s a balance between the two. Breaking things up into function does have advantages, but, as you say, it makes it more likely that you’ll have to jump around a lot to understand a single process.

      • gornius@lemmy.world
        link
        fedilink
        arrow-up
        1
        ·
        1 year ago

        I specifically have a rule that if at the current abstraction layer, a step is more than one function call/assignment - I’m creating another function for that.