0

We're in the middle of writing a new app from scratch and planning to use DDD for this but we're all new to the process and trying to figure things out. The app at its core is a video conferencing tool, but within that we've got a number of subdomains that we're looking at make bounded contexts

  • Meetings - managing the meetings themselves
  • Calendar - integration with calendars
  • Transcripts - processing transcripts from the calls

Probably some others, but these pieces feel like they're logically separate. The issue I'm now unsure about, is the database. We've got a single database for the application, but each of the bounded contexts will need to access data from the same tables.

For instance, the calendar integration will need to make changes to meeting records to reflect changes in the calendar. Transcripts will update the meeting to attach the links for the resulting files.

Obviously we could create an entity in each context to represent these, but underneath it's still the same database table.

Is this a problem? Or is it possible the app isn't even big enough to warrant bounded contexts at all?

4
  • 1
    I don't know that you'll find an "authoritative" answer to this. What would follow if, in addition to creating entities in each context, you were to also refactor the underlying table structure, such that each entity has its own table? If find that you cannot actually separate the tables (because $REASON), that tells you something important about the divisibility of the contexts. Commented Apr 25 at 13:52
  • Yeah that's a valid point. I don't think that it's so much they can't be separated, but more than it doesn't make sense to.
    – PaReeOhNos
    Commented Apr 25 at 14:27
  • 1
    Do you have 3 different teams, one for the "Meetings" service, one for the "Calendar" service and one for the "Transcripts" service? Or 3 different groups of business experts, one for each topic? If not, the answer to the question in your last sentence is probably "yes, it's not just possible, but likely".
    – Doc Brown
    Commented Apr 25 at 14:31
  • nah team is way too small for that. We're looking at DDD primarily as a way of keeping the codebase as clean and maintainable as possible. On the back end it's currently two engineers
    – PaReeOhNos
    Commented Apr 25 at 14:35

1 Answer 1

2

DDD Bounded Contexts has always been a somewhat vague idea. You can see that when you are speaking to "the business" about Domain Terms and the Domain Language you might get different parts of the business using different terms for the same thing, or the same term for different things. Thus you need some sort of context to keep them seperate whilst also using the Domain Language in your software.

How this translates to actual code though can be problematic.

My gut reaction to your description of the problem is that you don't have any Bounded Contexts or Bounded Context problems at all, just three separate products which will naturally have APIs they use to integrate with each other. Let's look at your example case:

For instance, the calendar integration will need to make changes to meeting records to reflect changes in the calendar

Rather than make changes to the table directly, I would have the the Calendar app make an API call to the Meeting app. "Meeting Date Moved"

That way the Calendar app doesn't need to know about any Meeting objects outside of the integration method signature.

Alternatively you could have an underlying EventsApi handling all sorts of events which both the Meeting and Calendar apps call for data.

In this case both apps might have their own Event objects populated from the underlying EventApi. the objects would have different methods and perhaps extra data added to them from other sources.

You would now need to talk about Bounded Contexts, because the word "Event" now has three meanings. But you still don't have any issues with database tables, because only the EventApi knows about the events table.

7
  • This sounds like a sensible approach. In terms of the context exposing a public API, what's the best way of modelling this? I've seen some places using service objects in the application layer, but presumably that's more for making changes. If (as per your EventsAPI example) I wanted to fetch data, what would be the cleanest option?
    – PaReeOhNos
    Commented Apr 25 at 14:32
  • im not sure what you mean here? use of REST apis to expose this kind of thing is pretty much universal, btu it would depend on how you app works
    – Ewan
    Commented Apr 25 at 14:34
  • We're not planning on splitting things into micro services, so all the code will reside in the same application. So it's more a matter of how one BC would ask another for data. It will technically have access to code within that BC, but obviously it should have 0 knowledge of its domain
    – PaReeOhNos
    Commented Apr 25 at 14:38
  • 1
    naming assemblies after layers can get you in a conways law type situation. What should be in domain vs application etc isnt objective. Really you have to choose whether you are going to put methods on your models OOP style, or have Anemic models with domain services. I would go with the second approach, assembly per service + one for models (per BC/sub application)
    – Ewan
    Commented Apr 25 at 15:52
  • 1
    Definitely going with the second approach of anemic models and services. The folder structure was just one taken from a series of other guides I've been reading through just to logically split the different layers but it's definitely optional
    – PaReeOhNos
    Commented Apr 25 at 16:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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