From a DDD perspective is a report generating service a domain service or an infrastructure service?

Posted by Songo on Programmers See other posts from Programmers or by Songo
Published on 2014-05-13T08:21:15Z Indexed on 2014/05/26 22:01 UTC
Read the original article Hit count: 291

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?

© Programmers or respective owner

Related posts about java

Related posts about design