MVC Vs n-tier architecture [closed]

2019-01-04 16:17发布

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

12条回答
劫难
2楼-- · 2019-01-04 16:55

The only similarity is that the two patterns have three boxes in their diagrams. Fundamentally they are completely different in their uses. If fact, it is not usually a choice between which pattern to use, but both patterns can be use together harmoneously. Here is a good comparison of the two: http://allthingscs.blogspot.com/2011/03/mvc-vs-3-tier-pattern.html

查看更多
戒情不戒烟
3楼-- · 2019-01-04 16:56

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

查看更多
smile是对你的礼貌
4楼-- · 2019-01-04 16:58

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.

查看更多
劳资没心,怎么记你
5楼-- · 2019-01-04 16:59

In a three-tier model all communication must pass through the middle tier. Conceptually the three-tier architecture is linear. However, the [model-view-controller] 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.

查看更多
爷的心禁止访问
6楼-- · 2019-01-04 17:06

An N-Tier architecture is best defined using a Deployment Diagram.

An MVC architecture is best defined using a Sequence Diagram.

The 2 are not the same and are not related and you can combine the two architectures together. A lot of companies have taken the steps to create N Tier'd architecture for not only deployment and scalability, but for code reuse as well.

For example, your Business Entity objects may need to be consumed by a desktop app, a web service exposed for a client, a web app, or a mobile app. Simply using an MVC approach will not help you reuse anything at all.

查看更多
别忘想泡老子
7楼-- · 2019-01-04 17:06

Conclusion : N-tier is an architecture, MVC a design pattern. They are the same metaphore applied in two different fields.

查看更多
登录 后发表回答