Mathematics I / Functions and Modularity
Practice question · Sort into groups

Sort each change to a function by whether existing callers keep working untouched.

Groups: Callers unaffected · Breaks callers

Hints
  1. Only the interface is visible from outside, everything else is private.
  2. Which changes alter what a call must supply or what it gets back?
Show the answer

Callers unaffected: Rename a local variable inside the body, Replace the body with a faster method giving the same results, Add a comment explaining the method

Breaks callers: Add a required second parameter, Change the function to return nothing

Why

Internal names, internal methods and comments are invisible to callers; changing the parameters or the return value changes the interface itself and every call site must follow. Knowing which is which is what makes modular code safe to improve.

Read the lesson: Functions and Modularity →

Practise Functions and Modularity

The app has 6 more questions on this lesson, and keeps your place in the course. Mathematics I is free to start.

More questions on Functions and Modularity