liveBook · Manning

Data-oriented programming

As explained in Data-Oriented Programming: Reduce software complexity

A programming paradigm that organizes software around data and seeks to reduce system complexity by separating data from code and avoiding unnecessary mutation and encapsulation.

Data-oriented programming (DOP) organizes software around data entities and stateless code modules. It aims to reduce complexity—the difficulty of understanding a system—by separating code from data, representing data generically, and treating data as immutable values. section 1.2 section 2.6

Consider a library system whose requirements keep changing. Instead of hiding member data inside objects and growing a class hierarchy for every membership rule, DOP keeps library data in data entities and places behavior in modules such as UserManagement, Catalog, and Library. New rules usually become new functions or small changes to existing functions. section 2.1 section 2.5

A DOP system follows several practical constraints:

  • Separate code from data: data entities contain members only, while code modules aggregate stateless functions. section 2.4
  • Pass manipulated data explicitly to functions rather than relying on an object’s implicit state. section 2.6
  • Represent records as heterogeneous string maps and collections as arrays, lists, vectors, sets, or other suitable collections. section 3.0 section 3.2
  • Keep module relationships to usage and data relationships to association or composition; avoid inheritance as the primary organizing mechanism. section 2.6 section 2.4
  • Treat primitive values and collections alike as immutable values when possible, making behavior easier to reason about. section 1.2.2

Adding library permissions

A stateless Library.getBookLendings function can receive libraryData, userId, and memberId, then call UserManagement.isLibrarian and Catalog.getBookLendings. To support Super members, add UserManagement.isSuperMember and extend the permission condition; the data model and overall module design remain unchanged. The same pattern lets VIP members call Library.addBookItem through a new UserManagement predicate. section 2.5

Reproducing a data scenario

Capture a function’s map and query arguments, paste them into a clean REPL session, and improve the function without repeatedly invoking the endpoint. A reproduced catalog search exposes a failing prefix search, after which the implementation can be changed and tested against the same data. section 15.3

Table 1.1 Aspects of OOP and their impact on system complexity (view table figure)

Aspect

Impact on complexity

Code and data are mixed.

Classes tend to be involved in many relations.

Objects are mutable.

Extra thinking is needed when reading code.

Objects are mutable.

Explicit synchronization is required on multi-threaded environments.

Data is locked in objects.

Data serialization is not trivial.

Code is locked in classes.

Class hierarchies are complex.

Compare how mixing code and data, mutability, encapsulation, and class-bound behavior increase understanding, synchronization, serialization, and hierarchy costs. section 1.2

How Data-Oriented Programming: Reduce software complexity covers it

How deep it goes
Works through architecture, data representation, permissions, database access, immutability, testing, and reproducible debugging.
Examples
Uses library permissions, map-based book records, relational database collections, and reproducible catalog-search debugging.
What it assumes
Assumes general programming familiarity while defining complexity, DOP terminology, data entities, maps, collections, and module constraints.
What you can do after
Apply it by designing stateless modules, generic records, explicit data flow, and reproducible data-driven debugging experiments.
How it connects
Connects separation of concerns, object-oriented programming, functional programming, immutability, serialization, databases, unit testing, and debugging.

Also explained in

Compare how 2 books explain data-oriented programming →

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.