---
title: "Interfaces, coupling and what a module promises"
description: "A module's interface states the public names and behavior callers may rely on. Coupling describes dependencies between modules. Depending on private details can increase the work caused by a change. A"
canonical: https://lightmysky.com/learn/computing/interfaces-coupling-and-what-a-module-promises-mt_EUZyD26WFk
source: https://lightmysky.com/learn/computing/interfaces-coupling-and-what-a-module-promises-mt_EUZyD26WFk.md
retrieved: 2026-11-12
---

> **Agent view.** This is the Markdown twin of the page, for tools and assistants.
> When to use this site, and the call that answers each job: https://lightmysky.com/agent-instructions.md
> API description (OpenAPI 3.1): https://lightmysky.com/openapi.json · Authentication: https://lightmysky.com/auth.md
> Pricing: https://lightmysky.com/pricing.md · Catalog: https://lightmysky.com/llms.txt · Full catalog: https://lightmysky.com/llms-full.txt
> Every machine-readable file on this domain: https://lightmysky.com/.well-known/ai-catalog.json
> Ask for Markdown with `Accept: text/markdown`, a `.md` address, or `?mode=agent`.

# Interfaces, coupling and what a module promises

A module's interface states the public names and behavior callers may rely on. Coupling describes dependencies between modules. Depending on private details can increase the work caused by a change. A compatible public contract can let a module change its implementation without caller edits.

Subject: Computing · Area: Software Engineering · Ages 19 to 20
Page: https://lightmysky.com/learn/computing/interfaces-coupling-and-what-a-module-promises-mt_EUZyD26WFk

## Ready when they can

- State the promise of a module without describing how it is implemented
- Find the place where one module reaches past another's interface
- Predict which of two designs makes a stated future change cheaper

## Lesson: Promises your modules keep

You have written testable requirements and assigned responsibilities to classes. A module groups related code behind an interface. That interface states the public names and documented behavior callers may rely on: accepted inputs, results, errors and promised effects. Private helpers and storage are implementation details. Internal changes must keep the public contract compatible.

**Example.** A stock module accepts a product ID and returns its available quantity or an unknown-product error. That describes observable behavior. Searching a private list with a loop describes one implementation. The module could use another storage method while keeping its contract. To write a behavior-only promise, state what callers supply and observe without choosing private storage or an algorithm.

In Python, the first ordinary import of a module executes its top-level statements. Later imports usually reuse the cached module. Defining a function does not call its body. To keep a demo from printing on import, indent it under `if __name__ == "__main__":`. The block runs when the file runs directly as a script, and is skipped on ordinary import. Keep reusable definitions outside it. The guard does not stop other top-level code.

After `import shapes`, use `shapes.Circle()`. After `from shapes import Circle`, use `Circle()`. After `import shapes as sh`, use `sh.Circle()`. A module prefix or its alias shows the origin at each qualified use. All three forms can use the same public class. Direct import alone does not mean dependence on private internals. A public rename can affect callers using any of these forms.

Coupling describes dependencies between modules. Reading private `_items` depends on that storage attribute. Calling public `total()` depends on its documented contract. Removing `_items` breaks a caller that reads it. A compatible `total()` can hide the storage change from its callers. Public names alone are not enough: changing promised results or errors also changes the interface.

*(drawing: The caller requests the total through a public operation instead of reading private storage.)*

**Example.** Compare designs against a specific change. Suppose a private `_lookup` helper is renamed while public `quantity()` keeps its name and behavior. A caller of `_lookup` needs an edit; a caller of `quantity()` does not need one for that rename. Separate caller edits from work inside the module. Dependencies affect change cost, but testing, implementation work and other factors also matter.

If an approved feature needs access the interface does not offer, request a documented public operation. For a tally reset, define the operation's effects and errors so the module can update its own counter. A caller that writes a private counter depends on its current representation. Copying the storage code into callers also spreads that dependency.

**Recap.** Rely on documented names and behavior. Keep private state behind public operations. Compare dependencies against a stated change, and guard demos that should run only as scripts.

*Lesson, questions and flashcards written for this dataset. Answer choices revised for this edition. Python textbook records on top-level code and using modules with classes informed the concept and exercise study; their prose and figures are not reproduced.*

## Practice

8 questions on this page, each with its working shown.

## Needs first

- [Designing with Objects: Deciding What Each Class Owns](https://lightmysky.com/learn/computing/designing-with-objects-deciding-what-each-class-owns-mt_De_gpvpOzg)
- [Requirements: turning a wish into a testable statement](https://lightmysky.com/learn/computing/requirements-turning-a-wish-into-a-testable-statement-mt_TFb-YNpvT1)

## Opens up

- [Test Doubles and Testing at a Boundary](https://lightmysky.com/learn/computing/test-doubles-and-testing-at-a-boundary-mt_4ep3SiMYNM)
- [Design patterns: naming a solution that keeps recurring](https://lightmysky.com/learn/computing/design-patterns-naming-a-solution-that-keeps-recurring-mt_bhUEk8PwBp)
- [Software Architecture: Layers, Services and Their Trade-offs](https://lightmysky.com/learn/computing/software-architecture-layers-services-and-their-trade-offs-mt_uz_OkFgysJ)
