HN user

jgstyle

4 karma

[ my public key: https://keybase.io/jgstyle; my proof: https://keybase.io/jgstyle/sigs/CoZlgpSu5W24EGFtaFTjAhglx4zc0wdRhHvsUX1YKk4 ]

Posts0
Comments5
View on HN
No posts found.

There’s nothing wrong with writing reusable functions, and most well-written functions will be reusable without adding any needless complexity. However, too often I’ve seen developers over-generalize a problem to the detriment of readability.

I think one of the main points why a lot of developers tend to over-generalize is because they are not specific enough with the name of the function they are trying to write. Although it looks dull, I find the best workflow is giving functions (or methods) very specific names.

I think there are two major advantages as to why you should do it: - the problem mentioned in the text of over-generalising is minimised since you are forced to think about what exactly that method should do when creating it, not while writing it. - other people using your code will (to a certain degree) instantly know, what the function method is doing without having to look at the code