How would you cleanly follow the Stepdown rule in C/C++?

Viewed 199

The Stepdown rule encourages to read the code like a top-down narrative. It suggests every class/function to be followed by those at the next level of abstraction so we can read the code descending in the level of abstraction.

In C/C++ you need to declare classes/functions before you use them. So how would cleanly apply the Stepdown rule here? What are some pros and cons of the following approach? Any better one?

void makeBreakfast();
void addEggs();
void cook();
void serve();

int main()
{
    makeBreakfast();
}

void makeBreakfast()
{
    addEggs();
    cook();
    serve();
}

void addEggs()
{
    // Add eggs.
}

void cook()
{
    // Cook.
}

void serve()
{
    // Serve.
}  
1 Answers
Related