Subject: Re: [boost] New libraries implementing C++11 features in C++03
From: Dean Michael Berris (mikhailberis_at_[hidden])
Date: 2011-11-24 07:57:40
On Thu, Nov 24, 2011 at 11:44 PM, Thomas Klimpel
> Dean Michael Berris wrote:
>> 3. I cannot, no matter how I look at your examples and the "logic"
>> behind the concept of local functions, comprehend why this is a good
>> way to organize code. Aren't we all past the phase yet of functions
>> that have more than 10 lines of code?
> What are you trying to say here? Is there something wrong with functions having more than 10 lines of code? Looking at my pieces of code I'm most proud of, all have at least one function with more than 10 lines of code. One of this pieces of code was a cache optimal heap. So I looked whether there is any heap implementation in boost that doesn't have at least one function with more than 10 lines of code. There are surprisingly many different heap implementations in boost. All have at least one function with more than 10 lines of code (even if I count only the body and remove all comments/empty lines).
I think you're missing the forest for the trees here.
What I'm saying is: If I had a choice between one function that
contains another function that has N+M lines of code total versus two
functions where one has N and the other has M lines of code, I'd say
functions with less code is better -- or mathematically:
For any (N,M) where N > 0 and M > 0, N < N+M and M < N+M.
If we agree that having functions that have less lines of code is
better than a function that has more lines of code for readability and
maintainability, then there's no logical reason to prefer one function
having more lines of code _when it itself contains another function
that can otherwise stand alone_.
> What I'm trying to say here is that separation of concerns (which is a good way to organize code) can't be measured in lines of code.
Sure, but readability and maintainability can be -- it's a physical
fact: if you read one line of code at X milliseconds, then by the
(simple) rule of multiplication more lines of code will take more time
to read. I haven't met a person yet who can maintain code without
reading it first.
-- Dean Michael Berris http://goo.gl/CKCJX
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk