2 Separation between code and data

 

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.
 

2.1 A whole new world

The first insight of Data Oriented Programming (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 Data-Oriented Programming:

[Note]  Note

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

The details of Principle #1 are summarized in 2.1.

Figure 2.1. The summary of Principle #1: Separate code from data
principle1 mindmap

We illustrate the separation between code and data in the context of the Library Management system that we introduced in chapter 1, and we unveil the benefits that this separation brings to the system:

  1. The system is simple: it is easy to understand
  2. The system is flexible and extensible: quite often it requires no design changes to adapt to changing requirements

2.2 The two parts of a DOP system

 
 

2.3 Data entities

 
 
 

2.4 Code modules

 
 

2.5 DOP systems are easy to understand

 
 
 

2.6 DOP systems are flexible

 

2.7 Summary

 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest