Sign up ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

I am just building a MVC .NET application, eventually this will use entity framework and the repository pattern to structure the program. The first release however will only be calling other jobs that run reports.

For this I was going to make the interface iReport of which another project (that can call Matlab) will implement and this way I have abstracted this report and can take away Matlab and replace it if need be with another system that can produce the report in question.

My question therefore is, presuming this is a good architecture, how to structure this, where to put this interface? Do I simply put it in a separate folder on the web app project?

This seems like a simple question but I tend to struggle with project layout as I want to make sure it is correct.

share|improve this question

put on hold as too broad by Bart van Ingen Schenau, Snowman, MichaelT, jwenting, durron597 yesterday

There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs.If this question can be reworded to fit the rules in the help center, please edit the question.

    
Will there be just this one interface, or many of them? –  RubberDuck 2 days ago

1 Answer 1

It's good to put the interface with the domain objects it references.

So if you have Report, ReportLine, ReportType... etc and IReportGenerator I would stick them all in a class library project, with a 'Interfaces' folder/namespace for the interface.

This way, everything can reference the domain project and implement stuff using the objects and interfaces, but can then choose the implementation of the interface they would like to use without having to reference anything extra.

If you end up having lots of separate services, say IReportGenerator, IReportEmailer etc etc at some point you might want to split these out from the domain model class lib, just because they have such differing responsibilities, or perhaps they have to reference other libraries (although you should try and avoid this in your interfaces)

In this case, I would put the interface with the first implementation you write. say you have ReportGenerator_MatLab, you can stick it in that class lib. As you only have the one implementation (plus a mock!!) your projects are going to be referencing it anyway.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.