-2

Let me start by saying my knowledge of microservices isn't as strong as it could be. My understanding of DDD is that we'd draw a bounded context over an entity and that would be our service.

How does this work if we're using a strongly typed language save to Postgres but also save the same model to ElasticSearch? Would this be considered the same bounded context or not?

Thanks!

1 Answer 1

3

Let me set the stage. A microservice is a self-contained(!) application that handles a single(~) small(~) business capability of a bigger system.

DDD is an idea that we shouldn't concentrate on technology, but use the actual domain to build our applications. Using the same language (words) and behavior (functionality) that are present / inherent in the domain.

A "bounded context" is again a self-contained, well-defined part of a business domain with its internal language and functionality. It is self-contained, because it doesn't need any "words" (things) from other contexts to make sense. It is well-defined, because it has explicit "bounds".

Neither of these has anything to do with how things are persisted. "Entities" are not database records, they are things that have their business-behavior as per the context they are in.

With that said, a single object can only belong in one context per definition. Rare exceptions may apply for objects explicitly made for communication between services.

4
  • I think you can be less condecending.
    – Quesofat
    May 9 at 16:04
  • 1
    @Quesofat what part do you consider condescending? Imo Robert gives a good, concise explanation of the important concepts you asked about, which makes sense because you stated you lack knowledge of those concepts.
    – Rik D
    May 9 at 16:41
  • @Quesofat There was no emotional content from my side. Tried to summarize/define all the terms you used and give you an answer. May 9 at 19:43
  • The crucial point of Robert's explanation is that you have to separate persistence from domain logic in your thought process. Think about the domain model as if you have an infinite amount of RAM and everything is in local memory. When you have that picture and you have drawn boundaries around your bounded contexts, you can introduce databases and persistence as a secondary concern where necessary and practically aids your business case.
    – Subhash
    May 10 at 17:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.