Last week I introduced the ASP.NET MVC framework by talking a bit about what the model, view and controller are.
In the comments, John Meyer said,
I respectfully disagree with your claim that the model is you BLL. MVC is a UI layer pattern, and as such all models, views, and controllers are strictly in the UI level.
While historically, MVC has been described in the way I stated–while the ASP.NET MVC guys have also portrayed the Model as BLL or below–I have to agree with John. Here’s why:
At least as far as ASP.NET is concerned, the model is inherited from a specific class. This means that any implementation code you place in the class will be forever tied to the class it inherits from.
So if in some point in the future you decide that a WebForms implementation would work out better for you, or you wanted to put a Windows Forms implementation on top of it, you’d have to do quite a bit of refactoring of your code just so you could.
If instead you treat the Model as a “View Model” as John suggests, and have the View Model call the Business Logic Layer, you end up with two major benefits.
First, your Business Logic Layer is completely decoupled from the View implementation. You are no longer forever tied to MVC as an architecture or ASP.NET MVC as the primary architecture. You can use whatever view implementation you want.
Second, you are not forced to put View specific data code in your Business Logic Layer. Doing so would cloud the actual implementation of your BLL and actually further couple your view layer to your BLL, something that third tier is specifically designed to avoid.
Based on the feedback from John and my own thinking on the subject, I recommend a three-tiered approach that places the MVC as the view entity calling the BLL from the Model of the MVC set, which would in turn call the Data Access layer.
Other post in ASP.NET MVC
- ASP.NET MVC - Model != BLL or DAL - February 11th, 2009
- Infinite 302 Loop - How would you even know? - March 11th, 2009
- ASP.NET MVC - Controller to View - October 30th, 2013
- WebForms vs MVC–The War Is Over - September 25th, 2014
- ASP.NET, Angular.js & html5mode - September 24th, 2015
- Using Node.js and Gulp with ASP.NET in Visual Studio 2015 - January 21st, 2016