Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DDD and data export system

I'm a beginner in DDD and am facing a little problem with architecture.

Our system must be able to export business data in various formats (Excel, Word, PDF and other more exotic formats).

In your opinion, which layer must be responsible for the overall process of retrieving source data, exporting them in the target format and preparing the final result to the user ? I'm confusing between domain and application responsibilities.

And regarding the export subsystem, should implementations and their common interface contract belong to the infrastructure layer ?

like image 758
Jo Randria Avatar asked Oct 08 '12 07:10

Jo Randria


2 Answers

Neither Application nor Domain layer or any other 'layer'. DDD is not a layered architecture. Search for onion architecture or ports and adapters pattern for mor on this subject.

Now to the core of your problem. The issue you are facing is a separate bounded context and should go to a separate component of your system. Lets call it Reporting. And as it's just a presentation problem, no domain logic - DDD is not suitable for it. Just make some SQL views, read them using NHibernate, LINQ2SQL, EF or even plain DataReaders and build your Word/whatever documents using a Builder pattern. No Aggregates, Repositories, Services or any other DDD building blocks.

You may want to go a bit further and make all data presentation in your application to be handled by a separate component. Thats CQRS.

like image 192
Bartłomiej Szypelow Avatar answered Oct 04 '22 06:10

Bartłomiej Szypelow


I usually take the simple approach where possible.

The domain code implements the language of your domain - The nouns, verbs etc.

Application code creates poetry using this language.

So in your example the construction of the output is an application concern, while the construction of the bits that the application will talk about (since you don't mention it) would the the domain concern.

e.g. if the report consists of sales data, that things like dates, bills, orders etc. would be abstractly constructed in the domain, while the application would concerned with producing documents using these.

like image 41
Preet Sangha Avatar answered Oct 04 '22 05:10

Preet Sangha