Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How MVC (ASP.NET MVC) band 3-tier architecture can work together?

I am writing a design document and people on my team are willing to do the move from ASP.NET WebForm to ASP.NET MVC. This is great, but I have a hard time to understand how MVC workswith in a 3-tier (Data Layer, Business Layer and Presentation Layer) architecture. Can we say that the Model, View and Controller are part of the Presentation Layer? Is the Model part of the Business Layer?

In brief, how MVC and 3-tier architecture can work together? Thanks for the help!

like image 975
Martin Avatar asked Nov 28 '22 11:11

Martin


2 Answers

The presentation Layer is your View.

The Data Layer is your Model (recommend looking at the Repository Pattern).

The Business Layer remains what it is.

The Controller can call the business layer for functionality when the object is loaded, or the model can call the business layer for functionality when a specific ViewModel is requested, but otherwise it remains the same.

The controller shouldn't have expansive business logic in it -- put that in its own self-contained DLL.

like image 42
George Stocker Avatar answered Dec 04 '22 23:12

George Stocker


I consider ASP.Net MVC to be in the presentation layer. The "Model" classes it uses are really View Models, which describe the data structures needed by your views. All of your business logic and data access should remain separate from your MVC models and controllers.

Also, the general "Best Practice" for MVC is to keep the controller code as simple as possible, which usually means introducing some for of application service into your business layer that handles the heavy lifting.

like image 77
ckramer Avatar answered Dec 05 '22 01:12

ckramer