Module

A module is a structural building block of a program. It is any discrete unit that encapsulates its own data and code behind a clearly defined interface, so that other parts of the system depend only on that interface rather than its internals.

Treating a module as a black box gives a well-designed system its modularity. The classic account of this idea is David Parnas’s paper On the Criteria to Be Used in Decomposing Systems into Modules (1972), which argued that modules should be organized around design decisions likely to change, rather than around processing steps.

In many programming languages, "module" is also the name of a specific language construct for grouping related code — a file or namespace of functions, types, and values that can be imported elsewhere, as in Python. Other languages use different terminology for essentially the same idea. Java calls the equivalent construct a package.

References

  • Parnas, D.L. (1972). On the Criteria to Be Used in Decomposing Systems into Modules. Communications of the ACM, 15(12).