Domain Driven Design, Git and Crypto

Reflections similarities and differences in thinking behind Domain Driven Design (DDD), version control systems like Git and crypto currency systems.

From Apple’s Core Data, used to manage a network of objects which can be made persistent and loaded upon demand.

DDD Compared to Apple’s Core Data

I would say that Apple technologies like Core Data seems to be an implementation of a lot of the ideas in Domain Driven Design. Core Data is a way for you to make object-graphs which can be stored and loaded from disk.

Domain Driven Design (DDD) vs Data Oriented Design (DOD)

In fact this has a lot in common with Data Oriented Design, popular in the gaming industry. In Data Oriented Design we also try to avoid direct pointer references but for different reasons. Data Oriented Design arose among developers programming the Playstation 3. It had a heterogeneous architecture with what we call the Cell processor. Performance was achieved by moving chunks of code to special coprocessors with their own memory. These programs could then run in parallel achieving higher performance.

struct Person {
char *name;
int age;
};
struct Person {
char name[40];
int age;
};
struct Point {
float x;
float y;
};

struct Polygon {
Point *points;
int no_points;
}
struct Point {
float x;
float y;
};

struct Polygon {
int offset;
int no_points;
}

Point points[1024]; // Points for all polygons

void drawPolygon(Polygon *poly) {
int offset = poly->offset;
moveTo(points[offset]);
for (int i = 1; i < poly->no_points; ++i) {
lineTo(points[offset + i]);
}
}
void drawPolygon(Polygon *poly) {
int offset = poly->offset;
Point *p = &points[offset];
moveTo(*p++);
for (int i = 1; i < poly->no_points; ++i) {
lineTo(*p++);
}
}
struct Rect {
Point min;
Point max;
};
struct Rect {
Point *min;
Point *max;
};

DDD, Identifiers and Pointers

So in DDD we follow a similar practice. We store references to objects using IDs. But these IDs would often be IDs for rows in a database, not necessarily offsets into arrays, as I showed in Data Oriented Design. We achieve some of the same advantages however. An object stored into database can reference other data stored in the database by using an ID, but you cannot have a persistent reference to another object in a database if it was a raw pointer.

  • You cannot store pointers in data structures which are to be made persistent.
The Git Data Model. Different commits can point to subsets of data found in other commits.

Domain Driven Design And Git

But there is more to Domain Driven Design than just using identifiers. Another important point is how the data store is never mutated. This is similar to get. In Git objects never get mutated. You only ever add objects. This is to never loose history.

  • Add four points to polygon
  • Remove a point from polygon
  • Change x-coordinate of third point to 20.
Hello world!

Domain Driven Design and Crypto Currencies

These kinds of concepts pop up in all sorts of concepts. Crypto currencies also deal with the same issue that you can never mutate data on disk. You cannot go in an modify an existing transaction. You can only add transactions.

Geek dad, living in Oslo, Norway with passion for UX, Julia programming, science, teaching, reading and writing.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store