2 Reduce system complexity by separating Code from Data

 

2.1 Introduction

As we mentioned in Chapter 0, the big insight of Data Oriented Programming (DO) 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 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 does not depend on data that is somehow encapsulated in the function’s context.

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: quite often, it requires no design changes to adapt to changing requirements

We show how to:

  1. Design a system where code and data are separate
  2. Write code that respects the separation between code and data.

This chapter focuses on the design of the code part of a system where code and data are separate. In Chapter 3, we will focus on the design of the data part of the system. As we progress in the book, we will discover other benefits of separating code from data.

2.2 The two parts of a DO system

2.3 Data entities

2.4 Code modules

2.5 DO systems are easy to understand

2.6 DO systems are flexible

2.7 Wrapping up

sitemap