Currently, I am moving an outdated application to a domain-driven design model, and I ran into this problem: The application is designed to manage a large number of contacts in real time, including checking for duplicates. Whenever someone saves a new contact, he must go through a second check with third-party software (mostly affinity search software). If it passes the test, the contact will be created in SQL, and a small subset of the contact (some of the main fields relevant for checking duplicates) must be stored in a third-party software database. Thus, the contact entity lives in two (synchronized) storage systems, but one system has only a small subset of fields,whereas SQL has 50+ contact fields.
Now I thought it would be nice to create two types for the โcontactโ (Contact and ContactShort). As a result, I would also have to create two repositories for these objects and use these repositories in the domain service, which is ultimately used to perform those operations in which I need software to check for duplicates (for example, Save / Paste methods).
Is there a good rule on how to approach this scenario?
EDIT: I still haven't found a final solution, but have thought a little more about it: It might be wrong to separate duplicate storage validation from SQL DB in this case. In fact, I think itโs wrong to expose third-party software methods. This is a clean infrastructure. Since the save operation should never be performed without re-checking, I think third-party software calls should be internal to SQLRepository. He should never leave the infrastructure level, since he will never be able to return a valid contact object. What do you think?
hoetz source
share