Timeline for When is it appropriate to make a separate function when there will only ever be a single call to said function? [duplicate]
Current License: CC BY-SA 3.0
24 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| May 20, 2022 at 17:58 | comment | added | Thorbjørn Ravn Andersen | This also gives you a natural location to put documentation. | |
| Jan 25, 2016 at 17:33 | review | Reopen votes | |||
| Jan 26, 2016 at 0:58 | |||||
| Jan 25, 2016 at 17:15 | history | edited | David | CC BY-SA 3.0 | Clarified the question to be about conditions |
| Jan 25, 2016 at 10:26 | history | closed | CommunityBot gnat Bart van Ingen Schenau Winston Ewert David Hammen | Duplicate of Is it OK to split long functions and methods into smaller ones even though they won't be called by anything else? [duplicate] | |
| Jan 25, 2016 at 6:22 | comment | added | Nils Göde | The answer is given here: cqse.eu/en/blog/the-real-benefits-of-short-methods | |
| Jan 25, 2016 at 0:45 | answer | added | Dewi Morgan | timeline score: 4 | |
| Jan 23, 2016 at 20:58 | answer | added | cmaster - reinstate monica | timeline score: 5 | |
| S Jan 23, 2016 at 20:11 | history | suggested | dlu | CC BY-SA 3.0 | Corrected apparent typo in first paragraph. |
| Jan 23, 2016 at 17:21 | review | Suggested edits | |||
| S Jan 23, 2016 at 20:11 | |||||
| S Jan 23, 2016 at 15:13 | history | suggested | MedK | CC BY-SA 3.0 | "functions will" instead of "function swill" |
| Jan 23, 2016 at 14:43 | review | Suggested edits | |||
| S Jan 23, 2016 at 15:13 | |||||
| Jan 23, 2016 at 12:34 | answer | added | dss539 | timeline score: 12 | |
| Jan 23, 2016 at 10:46 | comment | added | RemcoGerlich | Is there an obvious name for the function that lets you know exactly what happens in it? Then it probably makes sense to make it separate. | |
| Jan 23, 2016 at 5:43 | vote | accept | David | ||
| Jan 23, 2016 at 5:39 | answer | added | svidgen | timeline score: 1 | |
| Jan 23, 2016 at 2:52 | review | Close votes | |||
| Jan 25, 2016 at 10:31 | |||||
| Jan 23, 2016 at 2:46 | comment | added | user26452 | Also - this is not an answer - but my comment above only applies to functions with return values. Void functions (subroutines) that purely create side effects fall squarely into the "not worth the trouble" category, in my opinion. | |
| Jan 23, 2016 at 2:45 | comment | added | user26452 | This can also depend on the language you're using. A functional language that doesn't use a classical object-oriented approach could benefit greatly from function composition. It also encourages single-responsibility and testability. However, in a classical language without a functional slant, it might not be worth the trouble (dealing with access modifiers, reduced testability due to access modifiers, non-first-class functions....etc). | |
| Jan 23, 2016 at 2:28 | answer | added | Alexander Pogrebnyak | timeline score: 2 | |
| Jan 23, 2016 at 0:33 | answer | added | Michael Durrant | timeline score: 5 | |
| Jan 23, 2016 at 0:31 | answer | added | Nicol Bolas | timeline score: 40 | |
| Jan 23, 2016 at 0:19 | answer | added | Tulains Córdova | timeline score: 94 | |
| Jan 23, 2016 at 0:18 | comment | added | Ixrec | At this abstract level, no, not really. Single use functions are perfectly fine if separating out that piece of functionality improves the readability and/or testability of the code, which obviously you have to judge on a case-by-case basis. But long functions do have a habit of getting longer and more confusing over time, so when in doubt err on the side of small functions. | |
| Jan 23, 2016 at 0:05 | history | asked | David | CC BY-SA 3.0 |