Why and Who of DDD?

DDD (Domain Driven Design), I heard it some time around 2011 or 12 as a part of book club discussion. I went through the initial chapters of the book back then. Book felt very raw because of my inexperience during that time with the designs.

I got chance to view this video on youtube on What is DDD by Eric Evans, the author of DDD. I could now relate the pain of software design mentioned in the talk after two decades working in the field.

On the video timeline 1:22 , Eric says “when they look at some of the things we do, they say you know you don’t need all of that and truth and beauty. All that is needed is software that runs“. This is the part which struck with me the most.

If you ask people to think of a design given a usecase, they come back with tiers, layers, patterns and practices, backend architecture, front end patterns and all sort of technology aspects. They don’t see how the software is going to serve the customer or end user.

Just as an example, Eric started with a diagram for Cargo Routing service. Routing service which takes in Origin, Destination and CargoId and populates Cargo bookings table. That looked something like shown below.

Now the above view is technology view which is talking in terms of service, tables and requests. It is not a domain view.

Timeline 12:39 on the video discusses about creative collaboration of software and domain experts. Per Eric domain view or model is built during conversation with the people who are operating in the domain. In this case people who are dealing with shipping operations.

What I have seen in software development organization is that there is an intermediary group of people who act like a bridge between operations and software team. Software team is regarded as someone who will not understand the operations, and Operations/business are regarded as team which will not understand the technology.

Being the second hand information source, a lot of information is lost in translation. Sometimes, I have seen questioning a business or operations to understand the domain is treated like a taboo.

Although I see richness of DDD, I have not seen anyone asking questions in DDD way. I had been to workshops which lasted couple of days to a week at enterprise level, where most discussions happen around data sources and solving problems with existing design. Never had any discussions in a DDD way.

Ending Note

I use domain specific language while coding. Although variables and operations are named similar to domain language, what we can not do is identify the gaps in the design or mimic the real world operations. In my opininion DDD is meant to address that specific problem.

Minimal Dotnet API Thoughts

Ever since Donet MVC came in, controllers were part of the API or Web application. Now there is a twist when the concept of controller is missing with .net mininal API.

One of the reason I heard Microsoft brought minimal API is to help the polyglot programmers. A python programmer can switch to developing minimal API with less effort. I see the point, however C# is still language for development.

Another reason I heard they brought minimal api is to support microservice. On the Microsoft site explanation given is “Minimal APIs are architected to create HTTP APIs with minimal dependencies. They’re ideal for microservices and apps that want to include only the minimum files, features, and dependencies in ASP.NET Core.

There was one blog or discussion where the question was asked how micro should microservice be. Some said it should be implemented in 2 to 4 days, and some said based on complexity. There is no proper answer on how small the microservice be. Per this blog by Kyle “It’s this thought that “Microservices must be tiny” that leads us to our first problem“.

Ending Note

Minimal API is good with minimal dependency part. However is it a nudge to move towards microservice architecture? I am eager to see how Minimal API is going to take over.

Service Boundary

Is service an API hosted on a cloud or on-premise server which does CRUD operations on a database? Can service be hosted in the same process if not in an API?

In reality service can be hosted in the same process or outside the process. In other words to say service is not an API. When some one says user service, it is the only source of user and only source of operations on the user. There is nothing outside of user service which will manipulate the user data. It is the single truth for the user data.

Then how does user service looks like from architecture perspective? Like one shown below.

How can a User service look like from Technical Perspective?

In the technical view you can have user service contains several things going on inside it. It can have even more than one database inside, several processes running each doing different things. A batch job could be running within the service boundary. 

Notice that shipping service is recieving user feed via FTP. It is not an API call here unlike Profile and Billing services.

Shipping service can hold the cache of user data, but it will turn stale. It still need to go fetch the data from user service to refresh its cache.

Ending Note

We need to be careful designing the service. Service has a logical boundary, has reason for its existance and is a single authority of its data. There should not be two services accessing the same database. For example, Shipping service accessing the database of User Service.

Here is the link to a talk from Udi Dahan about service and its boudaries. Very insightful.