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?