Re:Functions Should Be Short And Sweet, But Why?
by gbog on Wednesday January 22, 2014 @03:23AM
(#7101462)
There is another way, we do not need to be either in a big spaghetti blurb or infinite micro onions spread all over the place in multiple files.
With some work and some luck:
- all functions are short enough but all of them do something more than just passing things around.
- there is never any ambiguity on where a function's implementation is to be found. (In Python, I prefer "import x.y.z" then "x.y.z.myfunc()" than using "from x.y.z import myfunc", for this reason)
- like-minded functions are grouped together.
- functions are nice enough (read: testable and tested enough) so that there is rarely a need to check its code to use it.
With some work and some luck:
- all functions are short enough but all of them do something more than just passing things around.
- there is never any ambiguity on where a function's implementation is to be found. (In Python, I prefer "import x.y.z" then "x.y.z.myfunc()" than using "from x.y.z import myfunc", for this reason)
- like-minded functions are grouped together.
- functions are nice enough (read: testable and tested enough) so that there is rarely a need to check its code to use it.