Some texts I've read regarding DDD indicate that an Application Service or a Command (CQRS) in the Application Layer closely mirrors a specific Use Case.
For simple use cases, this mapping makes sense, but in more complicated instances that require multiple user interactions, I'm trying to understand how to map the courser grained level of the API, without pushing application logic into the UI.
Example: - Imagine a Application Service:
ImportProductData(date_source)
- From a System / UI standpoint, when importing product data, we want to check if any of the products already exist, and if so, prompt the user whether they would like to proceed or not before continuing.
My usual approach: Expand the API to include:
DoesIncludeExistingProducts(data_source)
If returns true, Prompt the user whether they would like to proceed, then call.
ImportProductData(date_source, overwrite=True)
My question is whether this is moving to much of the Application Logic into the UI layer? (i.e. the UI is now controlling whether Products can be overwritten, and whether existing products should be checked before importing product data etc)
If it is, I can't picture how the Application and Domain Layers would handle this? Apart from:
Calling:
ImportProductData(date_source)
When if fails, check why it failed, and if due to a product already existing, prompt the user and call again with:
ImportProductData(date_source, overwrite=True)
This feels like a different way of doing the same thing as above.
This might seem a bit pedantic, but I'm trying to make an concerted effort to keep the Presentation Layer (MVC) as light and thin as possible.
Thoughts as to any more elegant solutions?