Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • 1
    I would do that is there were more places in my code where I would use that function. Creating a funtion which is only used once, seems a bit overdone to me. Commented Jul 18, 2018 at 7:32
  • @Michiel To me the functionality seems it would be common enough to stuff it in a utility library that you can consume in other projects. Also, functions don't have to be reused. Even if it is used only once - it still provides much better readability than the alternatives. Commented Jul 18, 2018 at 18:58
  • By wrapping the code in a function you're providing your reader with a concise 'what' is being done without the 'how'. If they care about 'how', they can dig into your function. I use this paradigm heavily in my own code - and I highly doubt you only write functions that are re-used. That would cause for some very long, obscure functions. Commented Jul 18, 2018 at 19:11