Re:Functions Should Be Short And Sweet, But Why?
by sigmaml on Wednesday January 22, 2014 @06:14AM
(#7101949)
I worked on a similar project; the US consultant insisted that each method should be less than 25 lines. The code involved several decision trees. This rigid limit made the code quite inconvenient to follow and enhance. After much sweat and swearing on both sides, the limit was increased to 40 lines!
Re:Functions Should Be Short And Sweet, But Why?
by lostcolony on Wednesday January 22, 2014 @08:35AM
(#7102429)
I've run into that.
Compounding that issue, I've run into cases where people pulled out code into functions, realized that in two places the behavior was ~slightly~ different, and they addressed it by adding a variable, 'shouldThing' or something, that serves just as a boolean flag as to which bit(s) of logic you should fire. So now rather than just have to focus on the code that needs changing, I've got to go to an entirely different section/file, and wade through code that doesn't even relate to what I'm trying to fix.
So yeah, small functions good, but you can take it to extremes.