I’m having some trouble defining bounded contexts that aren’t just application level singletons for all but the most isolated use cases. For example, think about an invitation program where users can invite other people to our platform. There are the following restrictions in place:
- Users can only have up to 5 invitations in-flight
- The same person can’t be invited by two different users
The first requirement nudges me to create a
UserInvitationsEntity, keyed by user id, so I can limit the number of invitations consistently. The second requirement makes me think about an
InvitationRecipientEntity, keyed by recipient email, to enforce the one invitation per recipient constraint. The only way I can think of to enforce both constraints consistently is to define an
InvitationProgramEntity that would encompass everything.
This scenario is only an example. This thought process to determine context boundaries led me all too often to define an entity that’s effectively a singleton, creating a bottleneck. I’d love to hear about your experience designing bounded contexts and heed any advice you might have to share.
Thanks a lot,