method too long should not take local functions into account
Nested functions should be counted as separate functions instead of as part of it's parent. They are a nice way to reduce visibility of code.
They are a nice way to reduce visibility of code.
Should this really be the goal, to reduce visibility? ;-)
I am not sure nested functions are such a good pattern, because if you are using nested functions you could have also written a normal method which could be reused and tested on their own. A nested function increases the complexity of the outer function.
Stop nesting functions but not all of them Does nested function promote clean code
Consider 2 public methods. Each of them calls a (different) private method. Without local functions both private methods are visible to both public ones. Uncle Bob himself describes in his videos about functions that those local functions is exactly what he would like to have in Java.
Testing is not a concern because local functions are private.
Your first link talks about performance of nested functions in javascript. It does not apply to C#.
But would this not increase the complexity (loc) of the outer function? Could you please make a concrete example?
Why should those two cases be treated differently? Semantically they are the same. The only difference is the scope. And reducing scopes is quite important. That's the reason why we have access modifiers don't we?
public void DoSomething()
{
if (CheckSomething())
DoSomethingElse();
bool CheckSomething()
{
return true;
}
}
public void DoSomething()
{
if (CheckSomething())
DoSomethingElse();
}
private bool CheckSomething()
{
return true;
}