Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DDD. Shared kernel? Or pure event-driven microservices?

I'm breaking my system into (at least) two bounded-contexts: study-design and survey-planning.

There's a concept named "subject" (potential subject for interviewing) in the study-design context. We also maintain associations between subjects and populations in that domain.

Now, in the survey-planning, we also need (some) information about the subject (for example: for planning a visit, or even for anticipated selection of questionnaire, in case the population the subject belongs to is known beforehand).

So, I need that "subject" in both contexts.

What approach should I pick? Having a shared kernel, as explained in Eric Evans DDD book? I don't mind (at least for now) having the two contexts sharing the same database.

enter image description here

Or... should I go pure microservice? Meaning: those two can't / shouldn't share database..., and in that case I might have to go the mirroring / duplicating route through event passing: https://www.infoq.com/news/2014/11/sharing-data-bounded-contexts

Any thoughts on which one is better, for the above situation?

Thanks!

like image 653
Cokorda Raka Avatar asked Mar 02 '17 18:03

Cokorda Raka


People also ask

What is shared kernel?

The Shared Kernel pattern describes a relationship between two bounded contexts and is used on a context map in CML. The Language Semantics page describes all relationship types that are supported in CML.

What is DDD in Java?

Domain-Driven Design (DDD) is a set of principles and tools that helps us design effective software architectures to deliver higher business value.

What are bounded context in Microservices?

A bounded context is simply the boundary within a domain where a particular domain model applies. Looking at the previous diagram, we can group functionality according to whether various functions will share a single domain model. Bounded contexts are not necessarily isolated from one another.

What is context map in DDD?

Context Maps describe the contact between bounded contexts and teams with a collection of patterns. There are nine context map patterns and three different team relationships. The context map patterns describe a variety of perspectives like service provisioning, model propagation or governance aspects.


2 Answers

The context for microservices is distributed systems. In any other situation it would probably be overkill. Shared kernel will eventually split. That is usually the case. You may start from it. Nothing wrong with that. However, it will not stay there.

like image 185
Sergiy Chernets Avatar answered Sep 28 '22 08:09

Sergiy Chernets


I recommend that you choose a event-driven solution, but not necessarily to use microservices. You could build an event-driven monolith in order to spend much less time on synchronizing the two models. When the application grows too big then you split the monolith into microservices. You could use CQRS to split event more the models into write and read. If you use event-sourcing things get even more interesting.

In my experience, with shared kernel, the models become god objects, one-size-fits-all kind of objects.

like image 35
Constantin Galbenu Avatar answered Sep 28 '22 10:09

Constantin Galbenu