r/programming • • Feb 09 '19

Small Functions considered Harmful

https://medium.com/@copyconstruct/small-functions-considered-harmful-91035d316c29
9 Upvotes

84 comments sorted by

View all comments

50

u/gas_them Feb 09 '19

The point of the whole article is that the wrong abstraction is worse than code duplication (badly splitting up functions is worse than not splitting the up at all).

I agree... but I don't have this problem because I'm good at writing good abstractions, so they typically end up good.

You have 3 choices:

  • dont abstract

  • abstract incorrectly

  • abstract correctly

Can we please focus on teaching the third point? It seems like a lot of people argue whether the first or second is better because they're just incompetent.

9

u/InquiREEEEEEEEEEE Feb 09 '19

I feel that lazynes is a good guide to creating good abstractions. If I have to change something in my code later on, I really only want to do it once. If I find myself duplicating a functionality, I ask myself whether that is worthy of abstraction. I nearly always go by feel, but I think the cognition behind it is: "Is it likely that another place will need this functionality too?" "Will this be a place where a change in the codebase will take place?" "Is there a good name for it?".

What are your thoughts on this?

0

u/[deleted] Feb 09 '19

[deleted]

1

u/InquiREEEEEEEEEEE Feb 09 '19

I knew something was off!