winform实现mvvm_在SwiftUI中实现MVVM

winform实现mvvm

Software architectures are powerful weapons for developers.

软件体系结构是开发人员的强大武器。

In iOS development, before SwiftUI came along, Cocoa MVC was the most suitable software architecture in most cases. (If you want to know about Cocoa MVC, refer my another article)

在iOS开发中,在SwiftUI出现之前,可可MVC在大多数情况下是最合适的软件架构。 (如果您想了解可可MVC,请参阅我的另一篇文章 )

But now, EnvironmentObject’s data binding feature in SwiftUI allows to implement MVVM architecture easily. So I think MVVM has become the standard software architecture in iOS app(in Swift UI) development.

但是现在,SwiftUI中的EnvironmentObject的数据绑定功能允许轻松实现MVVM体系结构。 因此,我认为MVVM已成为iOS应用程序(在Swift UI)开发中的标准软件体系结构。

In this article, I will describe what is MVVM and how to implement MVVM in Swift UI by creating a simple counter app.

在本文中,我将介绍什么是MVVM,以及如何通过创建一个简单的计数器应用程序在Swift UI中实现MVVM。

It’s difficult to use Software architecture in real applications just by reading.

仅通过阅读就很难在实际应用程序中使用软件体系结构。

So, let’s implement by yourself to understand MVVM by your heart ❤️

因此,让我们自己实施以真正了解MVVM❤️

什么是MVVM? (What is MVVM?)

MVVM is a software architecture invented by John Gossman in 2005.

MVVM是John Gossman在2005年发明的一种软件体系结构。

MVVM has three components Model-View-ViewModel

MVVM具有三个组件: M odel- V iew- V iew M odel

Note that View and ViewModel are connected with data binding to share ViewModel status.

请注意,View和ViewModel通过数据绑定连接以共享ViewModel状态。

Image for post

模型 (Model)

Model has domain logic and its data not related to UI. Model is the same as it is in other software architectures like MVC, MVP.

模型具有域逻辑及其与UI不相关的数据。 模型与其他软件体系结构(例如MVC,MVP)相同。

For example, accessing database, control device, calculate price, etc — every logics not related to UI are included in Model

例如,访问数据库,控制设备,计算价格等-模型中包含与UI不相关的每个逻辑

It’s important that Model is completely independent of View and ViewModel, it must be able to be built alone.

完全独立于View和ViewModel的模型很重要,它必须能够单独构建。

视图 (View)

View is a component for accepting user inputs and rende

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值