2

Let assume we have the following service whose responsibility is to generate Excel reports:

class ExcelReportService{
 public String generateReport(String fileFormatFilePath, ResultSet data){
 ReportFormat reportFormat = new ReportFormat(fileFormatFilePath);
 ExcelDataFormatterService excelDataFormatterService = new ExcelDataFormatterService();
 FormattedData formattedData = excelDataFormatterService.format(data);
 ExcelFileService excelFileService = new ExcelFileService();
 String reportPath= excelFileService.generateReport(reportFormat,formattedData); 
 return reportPath; 
 } 
}

This is pseudo code for the service I want to design where:

  • fileFormatFilePath: path to a configuration file where I'll keep the format of my excel file (headers, column widths, number of columns,..etc)

  • data: the actual records returned from the database. This data
    can't be used directly coz I might need to make further calculations to the data before inserting them to the excel file.

  • ReportFormat: Value object to hold the report format, has methods
    like getHeaders(), getColumnWidth(),...etc.

  • ExcelDataFormatterService: a service to hold any logic that need to be applied to the data returned from the database before inserting it to the file.

  • FormattedData: Value object the represents the formatted data to be inserted. ExcelFileService: a wrapper top the 3rd party library that generates the excel file.

Now how do you determine whether a service is an infrastructure or domain service?
I have the following 3 services here:
ExcelReportService, ExcelDataFormatterService and ExcelFileService?

asked May 13, 2014 at 8:21
1
  • If the report is part of the business process, it could very well be simultaneously a domain service and an infrastructure service. Although, it should be IOC'd out of the domain. Commented Oct 30, 2014 at 16:53

2 Answers 2

2

All of it is infrastructure service. Domain in DDD is primarily concerned with data and business rules that operate on this data. It has nothing to do with how the data are presented. So in your example, the only part that would be related to domain is how you get the data.

answered May 13, 2014 at 8:39
2
  • I see, so following your logic ExcelDataFormatterService shouldn't contain any business logic, just presentation logic, right? Commented May 13, 2014 at 8:52
  • @Songo Yes. Well, it could do a business logic, but only transitively, by calling some kind of domain class, which is not related to excel. Commented May 13, 2014 at 10:12
1

I think you may put it this way: in your specific case if the main purpose of the application / webservice / whatever you are developing is to make reports, then reporting tends to be considered a domain service. Otherwise it is an infrastructure service.

answered Jan 31, 2015 at 20:56

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.