Terminology – Principle That a Method Should Either Orchestrate or Do

principlesterminology

I recall a principle that a professor talked about while I was in school (back in the mists of time) that went something along the lines of "A method/function should either orchestrate other functions, or perform small, a specific task", but I can't for the life of me remember what the formal name of that principle is, beyond being a super-symmetric application of the Single Responsibility Principle.

Anyone know the name?

Best Answer

There is a principle that makes you do this but it doesn’t say it the way your professor did.

Every function orchestrates other functions. Even adding two numbers together and assigning them to a variable is orchestrating functions. You can twist yourself in knots thinking this way.

The single level of abstraction principle up holds the spirit of that idea but doesn’t require that you pretend you know where the bottom is. It only requires that you set a level of abstraction and stick with it.

That means this is not structural. It’s conceptual. It doesn’t matter if you mix functions from your own code, a library, or even the basic language functions.

What matters is that when you mix them together they don’t yo-yo your brain up to hand waving high abstraction and down to low level details all within the same function.

Do that and you’ll end up separating orchestrating and doing just fine.