▲ 342 ▼ What are your programming hot takes? (lemmy.ml) submitted 2 years ago by 257m@lemmy.ml to c/programming@programming.dev 886 comments fedilink hide all child comments
[–] TanakaAsuka@sh.itjust.works 28 points 2 years ago (2 children) 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. permalink fedilink source parent hideshow 4 child comments replies: [–] StudioLE@programming.dev 8 points 2 years ago (2 children) Yep. And three functions is better than one for legibility even if one would be fewer lines of code permalink fedilink source parent hideshow 4 child comments replies: [–] Feathercrown@lemmy.world 6 points 2 years ago (1 child) 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 permalink fedilink source parent hideshow 2 child comments replies: [–] Buttons@programming.dev 4 points 2 years 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. permalink fedilink source parent [–] gornius@lemmy.world 1 point 2 years 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. permalink fedilink source parent [–] ParsnipWitch@feddit.de 1 point 2 years ago I think they didn't mean how you structure your code but actually precision. permalink fedilink source parent
[–] StudioLE@programming.dev 8 points 2 years ago (2 children) Yep. And three functions is better than one for legibility even if one would be fewer lines of code permalink fedilink source parent hideshow 4 child comments replies: [–] Feathercrown@lemmy.world 6 points 2 years ago (1 child) 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 permalink fedilink source parent hideshow 2 child comments replies: [–] Buttons@programming.dev 4 points 2 years 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. permalink fedilink source parent [–] gornius@lemmy.world 1 point 2 years 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. permalink fedilink source parent
[–] Feathercrown@lemmy.world 6 points 2 years ago (1 child) 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 permalink fedilink source parent hideshow 2 child comments replies: [–] Buttons@programming.dev 4 points 2 years 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. permalink fedilink source parent
[–] Buttons@programming.dev 4 points 2 years 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. permalink fedilink source parent
[–] gornius@lemmy.world 1 point 2 years 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. permalink fedilink source parent
[–] ParsnipWitch@feddit.de 1 point 2 years ago I think they didn't mean how you structure your code but actually precision. permalink fedilink source parent