且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

3层和MVVM架构之间的区别?

更新时间:2023-12-04 12:26:52

这个错误认为一切都可以比较来自于?没有意义,真的。



只需了解两者:



http://en.wikipedia.org/wiki/3-tier_architecture [ ^ ],

http://en.wikipedia.org/wiki/MVVM [ ^ ]。



-SA
Where this false believe that everything can compare comes from? Makes no sense, really.

Just learn about both:

http://en.wikipedia.org/wiki/3-tier_architecture[^],
http://en.wikipedia.org/wiki/MVVM[^].

—SA


MVC与3层架构 [ ^ ]


3-tier Architecture

----------------------------

在3层架构中,用户界面层,业务逻辑层和数据库层就在那里。

In UI层,UI与Presentation代码和应用程​​序逻辑混合,这违反了SRP(单一责任原则)规则。



SRP:在面向对象的编程中,单一责任原则规定每个对象应该只有一个责任,并且该责任应该由类完全封装。它的所有服务都应该与这个责任完全一致。





MVVM架构:

---- ----------------

模型 - 视图 - ViewModel模式



在MVVM中的UI层分为两层。 ViewModel负责应用程序逻辑,而View只负责演示。

这可以让你做三件非常重要的事情:

1。更好的代码可维护性。



2.更容易与VS设计师合作。(这可以说是MVVM最强大的功能。它确实提高了生产力)



3.允许使用自动化测试来测试ViewModel,而到目前为止我们必须测试UI本身,并且在UI上进行自动化测试很复杂。这称为可测试性



由于这些原因,WPPF遵循这种模式。
3-Tier Architecture
----------------------------
In 3- tier architecture, the UI layer, the Business Logic layer and the DataBase layer is there.
In UI layer, the UI is mixed up with Presentation code and Application logic, this violates SRP(Single Responsibility Principle) rules.

SRP: In object-oriented programming, the single responsibility principle states that every object should have a single responsibility, and that responsibility should be entirely encapsulated by the class. All its services should be narrowly aligned with that responsibility.


MVVM architecture:
--------------------
Model- View- ViewModel pattern

In MVVM the UI Layer is separated into two layers. the ViewModel, which is in charge of the Application Logic, and the View, which is in charge solely on presentations.
This allows you three very important things:
1.Better Code Maintainability.

2.Easier to work with VS designer.(this is arguably the strongest feature of MVVM. It really boosts up productivity)

3.Allows for testing of the ViewModel with automated tests, whereas up until now we had to test the UI itself, and doing automated tests on UI is complex. This is called Testability

WPPF follows this patterns because of these reasons.