Reputation: 35318
I have an application that creates an MS Word document and runs it. I'm trying to figure out which layer to put that code in.
Would running the external document be part of the presentation layer or part of the business logic layer?
One the one hand, it seems like it should be part of the presentation layer since it ultimately results in something being "presented" to the user (albeit within an external application). On the other hand, it seems more like a business logic layer concern since the presentation layer might only want to be concerned with the current application's UI, and because all it's really doing when it comes down to it is running an external process -- something that could be used for multiple external processes which don't all have a "presentation" aspect to them.
Also, I'm not sure if SO is the right place for this question. I checked https://softwareengineering.stackexchange.com/ but there were only a handful of followers on those tags.
Upvotes: 0
Views: 151
Reputation: 2689
It depends what you mean by "part of the presentation layer". If you mean actual implementation then it's definitely not. Yes, the result is an opened Word document but this has nothing to do with the presentation layer of your application.
So your code should be the following:
public class BusinessLayerService
{
private IDocumentGenerator _documentGenerator;
public BusinessLayerService(IDocumentGenerator documentGenerator)
{
_documentGenerator = documentGenerator;
}
public void DoBusinessCase1()
{
// Do work here
_documentGenerator.GenerateDocument();
}
}
If you use any IoC container just register the required implementation (for web, windows, mobil or console application) on your application starup.
Hope it helps!
Upvotes: 0