You have a sequence of functions to execute. Case A: They do not depend on each other. Which of these is better?
function main() {
a();
b();
c();
}
or
function main() {
a();
}
function a() {
...
b();
}
function b() {
...
c();
}
Case B: They do depend on successful completion of the previous.
function main() {
if (a())
if (b())
c();
}
or
function main() {
if (!a()) return false;
if (!b()) return false;
c();
}
or
function main() {
a();
}
function a() {
... // maybe return false
b();
}
funtion b() {
... // maybe return false
c();
}
Better, of course, means more maintainable and easier to follow.