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)
Use the comparison table to inspect how object-oriented and data-oriented representations trade safety against flexibility and genericity. section 3.2








