liveBook · Manning

Coordinating function

As explained in Learn AI-Assisted Python Programming, Second Edition

A coordinating function is a function that primarily orchestrates calls to other functions rather than performing substantial work itself.

A coordinating function mainly orchestrates calls to other functions instead of doing substantial work itself. It can direct a sequence of smaller tasks, while helper functions perform focused work and leaf functions operate independently. section 3.5

Removing the work from funct1

In the function-call example, funct1 prints messages and calls funct2 and funct3. Remove its three print statements, and funct1 becomes a coordinating function: it only arranges calls to other functions. With the print statements retained, it both coordinates and performs work. section 3.5

Listing 3.1 Code to demonstrate how Python handles function calls
def funct1():
    print("there")
    funct2()
    print("friend")
    funct3()
    print("")

def funct2():
    print("my")

def funct3():
    print(".")

def funct4():
    print("well")
print("Hi")      #1
funct1()
print("I'm")
funct4()
funct3()
print("")
print("Bye.")

Use the listing to trace how funct1 coordinates calls to funct2 and funct3, then compare its role with the standalone funct4. section 3.5

How Learn AI-Assisted Python Programming, Second Edition covers it

How deep it goes
Defines the role through contrast with helper and leaf functions, using one small call-flow example.
Examples
Uses funct1 calling funct2 and funct3, with print statements removed to isolate coordination.
What you can do after
Evaluate/understand it by distinguishing orchestration from work performed by called functions.
How it connects
Connects function calls with helper functions and leaf functions.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn AI-Assisted Python Programming, Second Edition. The section links point to the parts of the book it draws on.