Inheritance across micro-service entities in Domain Driven Design

Viewed 121

I have a system, of micro services. A serviceH manages books. A serviceM manages magazines.

They provide RESTful interfaces to work with their entities.

Book domain and magazines domain - are different domains, as books and magazines are distributed and promoted totally differently.

Still there are cases, where some clients want to handle all printable media, as a generalization of books and magazines equally: Link those against shelf's, manage their authors etc.

Is it a good idea, introduce a printable media service, to model actions, properties, common for books, magazines?

So that a new printed-media can be introduced to this generalization, without touching the code for linking against shelfs?

Worth other words: how to handle inheritance in Domain Driven Design?

2 Answers

Be carreful, a domain is not a ressource-related thing, it modelize a business process.

Two directions :

  1. Because of your question, i'm not very sure that you have two subdomains for books and magazines. In one domain, you can perfectly have a Book class and a Magazine class whose inherites Media class.
  2. You can use a Shared Kernel, with it you can shared a subset of domain which Book and Magazine domain can share (http://ddd.fed.wiki.org/view/shared-kernel)

To go further, you can read the chapter 2 (Domains, Subdomains and Bounded Contexts) and 3 (Context Maps) of Implementing Domain-Driven design by Vaugh Vernon.

Ps : don't forget to spoke to domain experts before developping any system (no DDD without that).

I think creating a new microservice(Experience MS) is a good idea.

Create a new microservice with common domain model, which gets data from service Book and service Magazine. This way, it doesn't need any change in the existing business microservice.

As per the microservices architecture, Microservice can only be available through the REST endpoint of that microservice.

Related