2 Separation between code and data

A whole new world

This chapter covers

  • The benefits of separating code from data
  • Designing a system where code and data are separate
  • Implementing a system that respects the separation between code and data

The first insight of DOP is that we can decrease the complexity of our systems by separating code from data. Indeed, when code is separated from data, our systems are made of two main pieces that can be thought about separately: data entities and code modules. This chapter is a deep dive in the first principle of DOP (summarized in figure 2.1).

Principle #1 Separate code from data such that the code resides in functions, whose behavior doesn’t depend on data that is somehow encapsulated in the function’s ...

Get Data-Oriented Programming now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.