slash dev slash null

simbo1905’s ramblings about computers

Tag: DDD

Agile and Domain Driven Design (Part 4): Microservice Sagas

The last post discussed breaking up a digital service into bounded contexts that can be enhanced by small autonomous teams. A microservice architecture allows teams to focus on domain driven design by creating aggregate entities that enforce the invariants of a business. The catch to such autonomy is the price of the operational complexity of running a distributed system. Technologies such as Kubernetes and a Service Mesh help. Yet there remains an additional complexity that you have to abandon global transactions and the “I” of ACID updates. You also need to use asynchronous messaging and deal with eventual consistency. Why? Read the rest of this entry »

Agile and domain driven design (part 1): Digital Services

In the last mini-series of posts I sketched out how to use DDD to build an explicit rich domain library that models the business domain and enforces the invariants within a narrow scope of an aggregate of entities. Catching up with my friend we got into a discussion about how we get to the point were are ready to implement things. How big can the model be? How do we scale to many two pizza teams? How do user needs, business processes, and screens relate to the domain focused OO design? We ended up talking about microservices. So in this series of post I am going to sketch how a large scale agile digital transformation programme gets to the point of cutting DDD code. I will then get into how a large project comes to be a platform with a micro-services architectureRead the rest of this entry »

Domain Driven Design: Entities, Value Objects, Aggregates and Roots with JPA (Part 5)

This is the last article in the series which discusses a sample app that does DDD using JPA. I would hesitate to recommend using JPA for DDD unless you are very familiar with JPA. Why? Some of the issues you can hit using JPA are written up on the Scabl blog on Advanced Enterprise DDD. In my own code and this blog, I explained how to dodge some of the bullets, but you need to be quite aware of the pitfalls of JPA to dodge them all. So why did I write the code? Read the rest of this entry »

Domain Driven Design: Entities, Value Objects, Aggregates and Roots with JPA (Part 4)

Don’t abuse the `public` keyword in Java. The demo source code has very few public classes or methods. This is unusual for Java projects. Typically Java projects have package layouts that model the solution; “this package has all the entities, that package has all database related code, that package is all the services code.” That approach forces you to make almost everything public. There is no way the compiler can enforce boundaries that align to the business domain. In the long term, on a big project, many brittle connections will be made across business responsibility boundaries. Bit rot creeps into the design and your application becomes a big ball of mud. You should Tell Don’t Ask across domain boundaries in your application and align your package structure to the to the domains of your application and not any technical layers.  Read the rest of this entry »

Domain Driven Design: Entities, Value Objects, Aggregates and Roots with JPA (Part 3)

Where’s the application in the demo code? There isn’t one.

If you look at the source code there is no front-end, no web servlets, no screens, and no Java main class, and so no way to run it as an application. All that you can do is run the test class. So it is a library project. It is a rich “back-end” that can talk to a database. In this post, I will recommend that you don’t share such a library project between multiple teams.  Read the rest of this entry »

Domain Driven Design: Entities, Value Objects, Aggregates and Roots with JPA (Part 1)

A friend with a relational database background was working on an OO domain modeling problem. I started talking about “aggregates” and “roots” and things like “make the contract entity an aggregate controlling the other entities” and that “external logic should speak to the object model via a few root entities.” So I wrote demo project is some Spring and JPA code in Java to demonstrate those concepts. This blog series will be some discussion around the design and implementation techniques.  Read the rest of this entry »