One of the advantages of functions is that a well-named function is self-documenting. If you can take a bunch of lines and wrap them in a function whose name summarizes exactly what it does, then you have improved readability in my opinion. In this example, I don't really need to know the details of how the query parameters are extracted. I just want to know I've got them.
marginalia_nu|3 years ago
Maybe not relevant in simple toy examples, but you don't have to look far until to find a function that isn't so easy to name.
lamontcg|3 years ago
Usually when I see one-line functions they cost more in short term memory than they save. There's good exceptions to this with something like a horrible conditional that is necessarily horrible so you can bust it out into a method with a doc comment about the horribleness, its history, and its subtle madness. But developers that just break out one-line methods all over the place wind up writing hard to understand code.
nmz|3 years ago
dqpb|3 years ago
Naming is hard unless you have a sensible concept hierarchy, and then naming is easy.
Concept hierarchies are hard, unless you have a sensible system model, and then concept hierarchies are easy.
System models are hard, unless you have domain expertise, and then system models are easy.
rocqua|3 years ago
On the whole I think such functions are valuable. But they do have downsides.
watwut|3 years ago
I don't recall much jumping put and in.
patrick451|3 years ago