An less-known technique to dealing with nested-ifs is through the use of an one-time loop. Here's an example (in JavaScript):
function oneTimeLoopMethod(x) {
var result, temp = -1, a, b;
do {
... extra processing code ...
a = func_a(x);
if (!a) break;
... extra processing code ...
b = func_b(a);
if (!b) break;
... extra processing code ...
temp = b;
} while (false);
result = postProcess1(postProcess2(postProcess3(temp))); // This step can be more complicated.
return result;
}
It's useful when you want do additional processing before returning the final result to the caller. Because, otherwise, you'd have to duplicate the processing code in multiple places. When I first read about this technique, its description cautioned about the lack of clarity. So, use it at your own risk!