In JavaScript, PL/SQL and some other languages, functions can be nested, i.e. declared within another function. This could be used to break a large function into smaller pieces, but keep those pieces within the context of the larger function.
function doTooMuch() {
function doSomething () {
...
}
function doSomethingElse() {
...
}
function doYetAnotherThing() {
...
}
// doTooMuch body
doSomething();
doSomethingElse();
doYetAnotherThing();
}
In some cases, when those smaller functions do not use local variables of the larger function, this could easily changed to a version where all functions are unnested.
function doSomething () {
...
}
function doSomethingElse() {
...
}
function doYetAnotherThing() {
...
}
function doTooMuch() {
doSomething();
doSomethingElse();
doYetAnotherThing();
}
Assuming that those nested functions are not to be used anywhere else, is it better to keep them within the context of the large function or is it bad because this is exactly what makes the large function, well, large?