D
D
Dos2020-04-10 03:59:09
Software design
Dos, 2020-04-10 03:59:09

How to correctly implement the bounded context of cities?

The question of the correctness of the implementation of cities in the project in various contexts has long been tormented. I can't decide for myself how best to proceed.

I have different contexts that use cities, regions, countries. Addresses are also used.

If I understand the bounded context correctly, then it says that each context has its own entities. In my case, the city is used in different contexts . But to synchronize cities in every context is such an idea. I have three options for solving my problem:

1. Place cities in a separate GEO context and use only id cities in the GEO context in other contexts. Data will be added to the GEO context from the API of a third-party service.
2.Place your cities, countries, regions in each context .
3. Place the city on the entity that needs it instead of the city ID. But there is a question of normalization.

Tell me what is the best way to do it? What are good practices? Tell us how you approach this situation.

Thanks to all!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DarkTM, 2020-04-10
@DarkTM

In my opinion, there is an obvious option 1, cut from the city project into a separate entity, with its own api, and give cities and addresses.
In the second and third options, the DRY problem is immediately seen if cities and methods for them are repeated in several contexts.
In general, these are the basics ... sort of ... although it can only be for me, but if something is repeated in several places in your project, then you need to take it out into a separate entity, work as a separate module with its own API. It is easier to write a single API for all cities and a handler within each domain that needs this entity, and supplement it as needed, than to implement the same thing in each.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question