I'm reading through Mark Seeman's Dependency Injection in .NET (excellent read so far) and something is escaping me.
If the application's architecture is like
[DAL] => [BLL] <= [UI], with the Business Logic Layer free of dependencies upon Data Access and UI layers (and both dependent upon the BLL), and if the composition root is located in the UI layer, then how on Earth are we supposed to be able to bind the interface of a type in the BLL with an implementation that's in the DAL?
Mark Seeman gives a nice, typical example: abstract class
ProductRepository lives in the BLL and class
SqlProductRepository in the DAL. This may sound like a silly question but how is the UI layer supposed to be able to bind
SqlProductRepository without a reference to the DAL?
I move all the Controllers and ViewModels from the User Interface Layer to the Presentation Model layer, leaving only the Views (the .aspx and .ascx files) and the COMPOSITION ROOT in the User Interface layer.
Thing is, I'm pretty sure this guy knows what he's talking about, so what part have I missed?
Also where would I have to put the composition root in the case of a class library project? At first I thought the BLL would be perfect (given
[DAL] <= [BLL] => [UI]), but now that I've refactored my project to literally reverse the dependencies, I don't know anymore - I used to have a BLL that knew about both the DAL and the UI layer so binding the types of these layers was easy, now nobody knows about everyone anymore, it's like I don't have anywhere I could possibly put a composition root. Help me out here, I feel like I'm missing a fundamental cornerstone...