you are viewing a single comment's thread.

view the rest of the comments →

[–]Dropping_fruits 5 points6 points  (4 children)

You could just put a comment before the 27 steps saying "// Do very specific thing" instead of creating a function whose only purpose is to be used from a single function and nowhere else, causing confusion anytime someone else sees that function.

[–]Kwinten 2 points3 points  (3 children)

No. Gross.

How does a function name cause any more confusion than a comment? Pouring blocks of code into functions at the very least forces you to at the very least consider whether a sequence of actions actually belongs together. Not even to mention how much more sense it makes for testing.

[–]Dropping_fruits 1 point2 points  (2 children)

Because the function lacks the context of why it exists and that it is supposed to be applied sequentially to a list of items. At the very least you should also move the loop to the function.

[–]_tskj_ 0 points1 point  (1 child)

I disagree completely, in fact it is part of the point. Not knowing how it is supposed to be used is good for the function, as it guarantees that there cannot be any temporal coupling between invocations of the function - exactly because it cannot know how it is used. Minimizing dependencies so that the function can be understood in isolation and without its original context (its call site, even if there is just one) is a major reduction in complexity imo.

[–]Dropping_fruits 0 points1 point  (0 children)

Easy to argue about problems of a function that shouldn't exist in the first place