MVC vs. 3-tier architecture?

Model View-ControllerThree Tier

Model View-Controller Problem Overview


What is the basic difference between MVC and 3-tier architecture?

Model View-Controller Solutions


Solution 1 - Model View-Controller

3-tier is a Architecture Style and MVC is a Design Pattern.

so is Different in that.

but we could using mvc pattern in 3-tier architecture style.

so:

Presentation Tier: "Controllers and Views" from MVC Pattern.

Business Tier : "Model(Data)" from MVC Pattern.

Data Access Tier : Original Data Access Tier.

Solution 2 - Model View-Controller

In larger applications MVC is the presentation tier only of an N-tier architecture. The models views and controllers are only concerned with the presentation, and make use of a middle tier to populate the models with data from the data tier.

MVC can also be used as the entire 3-tier architecture where Views are your presentation, Controllers are your business logic and Models are your data layer (usually generated by a DAL such as Entity Framework).

Ideally though you want your controllers to be skinny and dumb, passing off logic to a 'business component', which would essentially become your middle tier.

Solution 3 - Model View-Controller

In the 3-tier architecture, communication between tiers is bi-directional. In the MVC the communication is in unidirectional; we could say that each "layer" is updated by the one at the left and, in turn, updates the one at the right –where "left" and "right" are merely illustrative.

3-Tier architecture usually deploy as 3 separate processes on 3 separate network nodes. But MVC is designed to deploy as a single process in a single network node. (like a desktop application)

Business tier in 3-tier usually contains different layers implementing famous patterns like business delegate, business façade, business object, service locator, data transfer object, etc. But MVC is a design pattern itself that is used in presentation tier.

The goal of 3-tier is separation of business logic from client and database, so provide multiple client protocols, high scalability, heterogeneous data access, etc. But the main goal of MVC is that implementation changes in one part do not require changes to another.

Solution 4 - Model View-Controller

There is no relationship between the two. MVC is a presentation layer pattern. The whole Model-View-Controller exists in presentation layer.

  • Model is object holding data (usually just VOs) which are represented by View or, populated from View.

  • Controller is what gets the request (and may populate the model) and calls the service layer. Then gets another (or same) model and sends it back to View.

  • View is what displays model, and provides components to capture user input. (It is usually a template engine in Web Applications, or UI components in a desktop application).

When talking about 3-tier (or n-tier) application we are talking about architecture of the whole application, which consists of Presentation Layer (the whole MVC), the Service Layer (Business classes), and Data Access Layer.

The Service Layer (and all behind that) are hidden behind the Controllers of MVC.

Solution 5 - Model View-Controller

I take a different approach compared to what Michael said in his response.

Controllers are never meant to be your business logic. For me, business logic belongs to the model layer. And though, views (and to some extent controllers) and part of the presentation layer, model is never a part of it in an MVC application. Model should be the heart and soul of an MVC application and that is what Domain Driven Design is all about which can be easily implemented in an MVC application.

Please remember that you don't have to have the model inside the same project (speaking of ASP.NET MVC). It could reside in an entirely different project and it can still act as a model to the application

An MVC application acting as a presentation layer only can work in a huge project with many tiers but it can never act as a presentation only layer in a 3 tier architecture which is what the questioner asked.

So we can say that MVC makes two (third can be the data layer which isn't really part of MVC architecture per se) out of three layers of a 3-tier architecture.

Thanks.

Solution 6 - Model View-Controller

IMO there is no direct comparison between 3-Tier architecture and MVC. Both are used in conjuction and hence we tend to see them through the same lense. Conceptually they need not to be used together. I could have 3-Tier architecture that does not use what MVC has to offer.

I am not elaborating the definitions part, but in nutshell:

3-Tier is a software architecture approach, in which the user interface, business process are logic, data tier developed independently, most often on separate platforms.

MVC has evolved from software pattern to architectural pattern over a period of time and is seen in all major frameworks nowadays.

Solution 7 - Model View-Controller

What is a 3-tier architecture?

Three-tier (layer) is a http://igoogle.posterous.com/3-tier-architecture-in-aspnet-with-c">client-server architecture in which the user interface, business process (business rules) and data storage and data access are developed and maintained as independent modules or most often on separate platforms. Basically, there are 3 layers, tier 1 (presentation tier, GUI tier), tier 2 (business objects, business logic tier) and tier 3 (data access tier). These tiers can be developed and tested separately.

DAL - Data Access Layer ( it has Connectionstring and Data read & execute process)

BOL - Bussiness Object Layer ( it has Queries )

UI - User Interface ( Forms & Code Behind )

More Details : http://igoogle.posterous.com/3-tier-architecture-in-aspnet-with-c">3 Tier Archtecture

Solution 8 - Model View-Controller

A 3-tier architecture is linear where the client tier never actually communicates with the data tier--all communication passes through the middle tier. MVC on the other hand is more triangular where the view sends updates to the controller and receives updates from the model and the controller updates the model.

(See "Comparison with the MVC architecture" on http://en.wikipedia.org/wiki/3-tier_architecture)

Solution 9 - Model View-Controller

Every Application has one are more of following Layers 1)Presentation Layer or UI Layer 2)Business Layer or Business Logic Layer 3)Data Access Layer or Data Layer

3-tier architecture usually has each layer separated by the network. I.E. the presentation layer is on some web servers, then that talks to back-end app servers over the network for business logic, then that talks to a database server, again over the network, and maybe the app server also calls out to some remote services (say Authorize.net for payment processing).

some times we requires more layers of the above type and more mechines then it is called as N-tier

MVC is a programming design pattern where different portions of code are responsible for representing the Model, View, and controller in some application. These two things are related because, for instance the Model layer may have an internal implementation that calls a database for storing and retrieving data. The controller may reside on the webserver, and remotely call appservers to retrieve data. MVC abstracts away the details of how the architecture of an app is implemented. Model on which model we wanted to build View means UI of the Application Contol Means the logic Which controls the Application

3-tier just refers to the physical structure of an implementation. These two are sometimes confused because an MVC design is often implemented using an 3-tier architecture.

Solution 10 - Model View-Controller

In MVC : MVC architecture is triangular: the view sends updates to the controller, the controller updates the model, and the view gets updated directly from the model

In Three Tier : A three tier architecture is the client tier never communicates directly with the data tier In a Three-tier model all communication must pass through the middle tier

Vikas Joshi Software Engineer

Solution 11 - Model View-Controller

My experience is that MVC is a just another "fad" term for badly-written 3-tier, where some of the communication jumps around the business layers, and thus the client and/or data layer also has business rules mixed in.

I hate code written like that - The term MVC must have been designed to confuse HR recruiters into thinking older programmers (who know it as "3-tier") are not matched for the job.

Solution 12 - Model View-Controller

  • 3-Tier is linear architecture. (Presentation tier -> Logic tier -> Data tier then Data tier -> Logic tier -> Presentation tier) But MVC is triangular architecture. (Control update View and Model. Model update View.)
  • MVC can include in presentation tier (Mobile applications, Angular like js frameworks etc...) and Logic tier (J2EE, Laravel, etc...) in 3 tier architecture.
  • Layers in 3 tier can implement in different network nodes. But typically elements in MVC implement in same network nodes.

Solution 13 - Model View-Controller

I dont think MVC will change anything or help you build better or robust system. 3 tier architecture is successful and sufficient system. I/you can build very comprehensive and robust system in it. We all know a complex or real life website takes a lot of interaction between all the layers. I personally believe php for that reason has advatage over .net. If u ask a nerdy ass arrogant programmer to build a simple forum system in .net he will scratch his head over which control to use to render it. Then he will combine data grid with some repeater... But later on if u simply ask to add comment section or image, he will be like how the heck i do it? On the other hand in php... U can mix in html with server code to achieve any presentation layer easily... So dont brag about architecture as they have equal advatages and disadvantages. But ask what have you built?

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionchhayaView Question on Stackoverflow
Solution 1 - Model View-ControllerF. FarjaminejadView Answer on Stackoverflow
Solution 2 - Model View-ControllerMichael ShimminsView Answer on Stackoverflow
Solution 3 - Model View-Controlleruser1954363View Answer on Stackoverflow
Solution 4 - Model View-ControllerAmir PashazadehView Answer on Stackoverflow
Solution 5 - Model View-ControllerImran RashidView Answer on Stackoverflow
Solution 6 - Model View-ControllersanjeevView Answer on Stackoverflow
Solution 7 - Model View-Controlleruser851253View Answer on Stackoverflow
Solution 8 - Model View-ControllerOCDevView Answer on Stackoverflow
Solution 9 - Model View-Controllerketan italiyaView Answer on Stackoverflow
Solution 10 - Model View-ControllerVikas JoshiView Answer on Stackoverflow
Solution 11 - Model View-Controlleruser1230575View Answer on Stackoverflow
Solution 12 - Model View-ControllerDinuka ThilangaView Answer on Stackoverflow
Solution 13 - Model View-ControllerSonny RahmanView Answer on Stackoverflow