liveBook · Manning

Flexibility

As explained in Data-Oriented Programming: Reduce software complexity

The degree to which a software system can adapt to changing requirements without requiring changes to its design.

Flexibility is the ability to adapt to changing requirements without changing a system’s design. Data-oriented programming (DOP) pursues it by separating code from data and representing data entities as generic maps rather than classes. section 2.6 section 3.2

The tradeoff becomes visible in everyday design choices:

  • Map-based records allow fields to be accessed and selected flexibly, while class-based records offer greater safety but less flexibility. section 3.2 section 10.2
  • Separating data from stateless functions lets developers design code and data in isolation and adapt them independently. section 2.6
  • The gain in adaptability comes with lower safety and more generic data structures than traditional object-oriented designs. section 3.2

Selecting database fields without a class

A member map can contain email, encryptedPassword, and isBlocked. Lodash’s _.at(member, ["email", "encryptedPassword"]) extracts the values required by an INSERT statement, without requiring a Member class or fixed access pattern. section 10.2

Table 3.1 The tradeoff among safety, flexibility, and genericity (view table figure)

 

OOP

DOP

Safety

High

Low

Flexibility

Low

High

Genericity

Low

High

Use the comparison table to inspect how object-oriented and data-oriented representations trade safety against flexibility and genericity. section 3.2

How Data-Oriented Programming: Reduce software complexity covers it

How deep it goes
Explains flexibility through code-data separation, heterogeneous maps, stateless functions, and explicit safety tradeoffs.
Examples
Uses Watchmen records, JavaScript and Java maps, member database insertion, and Lodash _.at.
What you can do after
Apply it via maps and stateless functions to adapt data representations and select database fields flexibly.
How it connects
Connects data-oriented programming with object-oriented programming, data encapsulation, stateless functions, hash maps, and genericity.

Also explained in

Compare how 9 books explain flexibility →

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.