0

I have been learning DDD and keep getting stuck at domain separation. I'm currently tackling a "Product Catalog" domain. Now in this domain some products are missing a description or image. I would like to add them if they are missing from outside sources.

Currently I have 2 models: "Product" and "RemoteProduct". RemoteProduct only has a subset of the same information as Product. They each have a repository.

My product repository would need a "GetAllMissingDescription" and "GetAllMissingImage". From a business perspective a catalog has no need to search for these 2 things so it seems like this doesn't belong in this domain. Yet all the functionality besides searching and populating this data would be the same.

Is this task suited for the "Product Catalog" by creating a service? Would it make more sense to create a "Product Catalog Updater" domain? Perhaps do this outside of DDD and create a self contained script. Or have I been doing this all wrong?

  • From a business perspective a catalog has no need to search for these 2 things -- From a business perspective, are you required to display images in the catalog? If you are, then a search for missing images is in scope by definition, especially if it's a requirement. In other words, I would expect the "display images" functionality to do whatever it needs to do to display images. – Robert Harvey Jul 31 '17 at 20:30
0

I would like to add them if they are missing from outside sources.

Does your domain have any reason to understand the detail of whether a product's description or image came from an outside or "inside" source?

Unless you have a compelling reason to express this detail in the domain it's best hidden behind an abstraction that gets image and description "somehow" without telling us how.

By walling it off like that your domain business rules don't have to know how you got product info. People reviewing them wont have to think about it.

When you use a vending machine do you want the life history of the product or do you just want the product?

  • I have no reason to maintain where the details came from after the first check because it will be saved in the database. As far as abstracting would it be best to create a service called "RemoteProductScraperService" that accepts a Product and RemoteProduct? The actual details I've omitted since they are irrelevant. – Lombar Jul 31 '17 at 22:36
  • Sounds like the domain doesn't need to know. – candied_orange Aug 1 '17 at 2:25

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.