tags:

views:

44

answers:

1

I have two separate functions, bar() and foo(). The execution flow of my program supposed to be as follows:

input -> bar() -> foo() -> output

Currently, a teammate of mine on the same development team made a foo() call inside the bar() function, which destroyed the modularity design. While it's better from modular design perspective to wrap bar() and foo() calls in a wrapper function called procedure() for example, would it cost any performance in terms of adding an extra function overhead on the program stack? I plan to encapsulate the procedure functions as follows:

procedure(inputs)
{
    bar();
    foo();
}

Thanks in advance for the advices.

+2  A: 

The overhead of a function call (especially with few local variables) is so small that it isn't even worth considering. Plus, a good compiler would inline calls where appropriate. I have always believed that good engineering should be the highest priority, since the overall efficiency gained from good design is often better than optimizing small things and leaving the overall design a spaghetti mess.

Joe M
Thanks for your comments. It's also what my instinct says as well in terms of the best decision.
stanigator