Imagine I have this code:
public void Foo()
{
// Do bar work
// Do baz work
// Do foobar work
}
And I realize I can (and should because it was doing more than one thing) refactor it into:
public void Foo()
{
bar();
baz();
foobar();
}
private void bar() { /* do bar work */ }
private void baz() { /* do baz work */ }
private void foobar() { /* do foobar work */ }
But then I realize I will never use these functions outside of Foo()
, so those functions are just cluttering the main page and the auto-complete. I could get away with this:
public void Foo()
{
bar();
baz();
foobar();
void bar() { /* do bar work */ }
void baz() { /* do baz work */ }
void foobar() { /* do foobar work */ }
}
Which would make things neater and less clutter, but all I've really done now is made the method even longer instead of shorter.