chapter ten

10 Data Oriented Architecture

 

This chapter covers

  • A way of thinking about the world
  • The role of objects in Data Oriented Programming
  • Drawing architectural boundaries

This chapter is about how to organize programs around data. That means, perhaps unexpectedly, that this is the chapter where we’ll spend the most time talking about objects. In data-oriented architecture, objects still reign supreme, but over a different kingdom than their usual one. We use them as gatekeepers with one purpose: exchanging data.

But beyond discussions about data and objects, the goal of this chapter is to give you a philosophy of architecture, something stronger and more bedrock than design patterns -- what Erlang’s creator calls “a way of thinking about the world.”

Or, as we’ll see, a way of thinking about worlds.

10.1 A small example

Let’s ingest some data. Here’s the setup:

Figure 10.1 The basic setup we’ll use to explore code architecture. It’s ambiguous by design!

Our service will read data from an external team's file store, lightly transform it, and then save it to our database. The data is standard finance stuff: Accounts, Invoices, and Disputes. Each month, this other team produces new files and then calls our API with a manifest describing where we can find them.

Listing 10.1 They call our service with a manifest describing the latest files
{
    "accounts": "{uuid}.csv",  
    "invoices": "{uuid}.csv",
    "disputes": "{uuid}.csv"
}

10.1.1 Starting from scratch

10.2 The Object Oriented Thought Process

10.3 The Data Oriented Thought Process

10.3.1 Resist the urge to abstract!

10.4 A way of thinking about software architecture

10.4.1 Start in the middle

10.4.2 The role of objects in data-oriented programming

10.4.3 Designing objects with functional core; imperative shell

10.4.4 Keep resisting the urge to abstract!

10.4.5 But what if it changes?

10.4.6 Push your semantics into the external worlds

10.4.7 Checks and balances

10.4.8 Dealing with the outside world that uses our program

10.4.9 Always watch your boundaries

10.5 Good boundaries make change easy

10.6 Wrapping up

10.7 Summary