In the ideal situation, one would return a value at the end of the function which tells how the function has finished. Avoiding the use of many multiple returns and avoiding large complex functions would lead to implementing many relative small functions which return a value. Depending on that value one would go further or not. So function-structures like these appear:
Code:
retval = function_a ();
retval &= function_b ();
if (retval == TRUE)
{
retval = function_c ();
if (retval == TRUE)
{
retval = function_d ();
retval &= function_e ();
if (retval == TRUE)
{
retval = function_d ();
}
}
}
To avoid function structures like this, one could combine functions. For example:
Code:
retval = function_ab ();
if (retval == TRUE)
{
retval = function_c ();
if (retval == TRUE)
{
retval = function_de ();
if (retval == TRUE)
{
retval = function_d ();
}
}
}
But it is not always desirable to combine functions, since other functions may only want to use function_a() or function_b().
Having many small functions, leads to a lot of function calls. And when combining a lot of combined functions, this leads to a lot of duplicate code which is hard to maintain. Since when function_a() changes, you'll also have to change function_ab().
Therefore I think that multiple returns are okay when used with care.