Function Length
During my career, I've heard many arguments about how long a function should be. This is a proxy for the more important question - when should we enclose code in its own function? Some of these guidelines were based on length, such as functions should be no larger than fit on a screen [1]. Some were based on reuse - any code used more than once should be put in its own function, but code only used once should be left inline. The argument that makes most sense to me, however, is the separation between intention and implementation. If you have to spend effort into looking at a fragment of code to figure out what it's doing, then you should extract it into a function and name the function after that “what”. That way when you read it again, the purpose of the function leaps right out at you, and most of the time you won't need to care about how the function fulfills its purpose - which is the body of the function. Once I accepted this principle, I developed a habit of writing very small fu
Function Length 30 November 2016 Martin Fowler metrics programming style During my career, I've heard many arguments about how long a function should be. This is a proxy for the more important question - when should we enclose code in its own function? Some of these guidelines were based on length, such as functions should be no larger than fit on a screen 1 . Some were based on reuse - any code used more than once should be put in its own function, but code only used once should be left inline. The argument that makes most sense to me, however, is the separation between intention and implemen
Explore this link on the map →saved by
related reading
- Ninja codejavascript.info
- Cognitive load is what mattersminds.md
- CSC 151 - Code Formatting and Styleeikmeier.sites.grinnell.edu
- CSC 151 - Documenting Your Codeeikmeier.sites.grinnell.edu
- abseil / Performance Hintsabseil.io
- GitHub - johnousterhout/aposd-vs-clean-code: A discussion between John Ousterhout and Robert Martin about differences between John's book "A Philosophy of Software Design" and Bob's book "Clean Code". · GitHubgithub.com
- Long Names Are Long - journal.stuffwithstuff.comjournal.stuffwithstuff.com
- A practical introduction to functional programmingmaryrosecook.com
- Succinctness is Powerpaulgraham.com
- An introduction to functional programmingcodewords.recurse.com
- From Imperative to Functional: how to make the leap.loup-vaillant.fr
- Google Testing Blog: Simplify Your Code: Functional Core, Imperative Shelltesting.googleblog.com