tags:

views:

6153

answers:

8

Hi

I was wondering what exactly is the difference between MVC(which is an architectural pattern) and an n-tier architecture for an application. I searched for it but couldn't find a simple explanation. May be I am a bit naive on MVC concepts, so if anyone can explain the difference then it would be great.

cheers

+17  A: 

N-tier architecture usually has each layer separated by the network. I.E. the presentation layer is on some web servers, then that talks to backend 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).

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.

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

Zak
+1  A: 

Zak are you saying that MVC is the same as N-tier architecture. I still don't get the difference. Could you refer us to some other online resources for further clarification.

From Wikipedia: The concepts of layer and tier are often used interchangeably. However, one fairly common point of view is that there is indeed a difference, and that a layer is a logical structuring mechanism for the elements that make up the software solution, while **a tier is a physical structuring mechanism** for the system infrastructure. http://en.wikipedia.org/wiki/Multitier_architecture
Robert Harvey
-1 This is not an answer, should be a comment
Willbill
A: 

Jerry: Here's a simple example of how the two are related:


Tier 1 - Consists of Models that communicate with Tier 2 through some sort of network service or similar, controllers to handle input validation, calculations and other things relevant for the views. And it contains the views themselves, ofcourse - which can be the GUI in a desktop-app, or the web-interface in a web-app.


Tier 2 - Contains some sort of service or other way of recieving messages from Tier 1. Does not/should not know about Tier 1, so can only answer to calls from above - never ask for things by itself. Also contains all business-logic.


Tier 3 - Contains the domain model, object representation of the database and all logic to communicate and update database-entries.

Arve Systad
+3  A: 
Xinus
A: 

A fundamental rule in 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 middleware tier.

It’s liner architecture. This addresses the question of how to pass information between a user and a database. Where as MVC is a triangular architecture: the View sends updates to the Controller, the Controller updates the Model, and the View gets updated directly from the Model. This addresses questions of how a user interface manages the components on the screen.

pooja gupta
Why down vote? This was a well put statement
contactmatt
A: 

you explain clearly still im not clear.Can you explain about middleware.

Cherry

Cherry
+1  A: 

If a 3-tier design were like this:

Client <-> Middle <-> Data

the MVC patter would be:

     Middle
     ^    |
     |    v
Client <- Data

Meaning that:

  • in the 3-tier equivalent, communication between layers is bi-directional and always passes through the Middle tier
  • in the MVC equivalent 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

P.S. Client would be the View and Middle the Controller

void