1 Data Oriented Programming
This chapter covers
- Introducing Data-Oriented programming
- Data as Data
- How representation affects our programs
This book is about data. It covers what it is, how to think about it, how to represent it in our code, and all the good things that happen when we do. Programs organized around data are simpler, smaller, and easier to understand.
The central idea of data-oriented programming (DoP) is modeling data “as data” in Java. That means representing it as ordinary values out in the open, liberated from the confines of private instance state. We’ll still use objects and object-orientation, but data is the building block around which we design. We’ll use it to encode business rules into the type system, make illegal states impossible to represent, draw architectural boundaries, enforce domain semantics, and create tests so powerful that they can prove entire features are correct.
The goal of the book is to teach you how to apply DoP to complex, real world software services. We’ll touch on financial systems, rocket manufacturing, rules engines, and more. In some chapters we’ll build these systems from scratch; In others, we’ll drop into legacy ones and focus on refactoring. You’ll see where DoP works, where it doesn’t, and how it fits into the wider Java landscape.