Given a code project which is supposed to adhere to the SoC principle by implementing loosely coupled layers, having an IoC container, etc., for example, a simple ASP.NET MVC solution which is separated into the following assemblies:
- Application assembly+namespace
- Model assembly+namespace (contains a concrete repository to access DB data)
and where a concrete repository in the Model assembly must implement a common interface IMyBusinessRepository
, in which assembly would you put that interface?
1) If you put that interface in the Model assembly, chances are that it would be impossible to replace that assembly by another one (at least if it has a different namespacing) without modifying the code of the Application assembly. Also, an alternative IMyBusinessRepository
implementation residing in a different assembly would have to reference the original one (Argh!)
2) If you put it in the Application assembly, it would be impossible to use the Model assembly in other projects without referencing the Application assembly (Argh!)
3) Or would you create a separate common assembly just for that interface, and for that matter, for each common interface or set of interfaces? (Argh?)
To summarize, X assembly should be easily replaceable in application A (merely by changing a reference), and reusable in applications B, C, D.