liveBook · Manning

Module

As explained in Data-Oriented Programming: Reduce software complexity

A software unit that aggregates stateless functions separately from the data entities those functions manipulate.

A module is a software unit that gathers related functionality into stateless functions, keeping those functions separate from the data entities they manipulate. In a library system, exposed operations such as searching, borrowing, returning, and blocking members form an API-facing module. section 2.0 section 2.3

Design a module by following these constraints:

  • Aggregate related functionality, often beginning with the verb phrases in system requirements. section 2.3
  • Keep every function stateless: pass the data it manipulates as an explicit argument instead of hiding state in the module. section 2.1 section 2.6
  • Expose the functions required by the system’s external interface, while leaving internal functionality unexposed when appropriate. section 2.3
  • Use module relations based on usage rather than inheritance, preserving a clear separation between code modules and data entities. section 2.4 section 2.6

Making state explicit

An object-oriented method might reach library state through an implicit receiver: getBookLendings(userId, memberId). A module function makes that state visible: getBookLendings(libraryData, userId, memberId). The function can then be considered independently from the data structure it receives. section 2.3 section 2.6

Figure 2.4 The Library module contains the exposed functions of the Library Management System.

Use the Library module diagram to inspect how externally exposed functions are gathered into one high-level module. section 2.3

How Data-Oriented Programming: Reduce software complexity covers it

How deep it goes
Defines stateless functions, explicit data arguments, usage-only module relations, and the contrast with implicit object state; defers polymorphism.
Examples
Uses a Library module containing search, borrowing, returning, blocking, login, and lending-list functions.
What it assumes
Requires no functional-programming theory and applies in both object-oriented and functional languages.
What you can do after
Build it from scratch by extracting functionality from requirements, grouping exposed functions, and passing manipulated data explicitly.
How it connects
Connects code modules with data entities, stateless functions, data encapsulation, object-oriented programming, and functional programming.

Also explained in

Compare how 35 books explain module →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Data-Oriented Programming: Reduce software complexity. The section links point to the parts of the book it draws on.