MVC多层移动应用 [英] MVC multi-tier mobile application

查看:20
本文介绍了MVC多层移动应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对使用 MVC 模式有点困惑.我们有一个三层架构:数据、中间件、前端.我们正在为 iPad 开发一个应用程序,它主要执行以下操作:

I'm a bit confused about using the MVC pattern. We have a 3-tier architecture: data, middleware, front-end. We are developing an app for iPad which basically does the following:

  • 使用 JSON 服务
  • 以某种 UI 形式显示结果
  • 用户交互(点击图标)/修改(编辑一些输入)
  • 重复...

一个业务流程在前一个流程的 n 次迭代后完成,即我们消费一个服务并更新屏幕,用户做了一些事情,我们使用来自前一个服务的响应数据加上一些其他用户输入作为参数传递给第二个请求,然后第二个请求的结果提供给第三个,依此类推,直到过程完成.

A business process is completed after n-iterations of the previous flow, that is, we consume a service and update the screen, the user does something and we use the response data from the previous service plus some other user input as the parameters to a second request, then the results of the second to feed the third, etc. until the process is finished.

我的问题是我真的不明白 MVC 模式是如何适应的.我只在前端层工作(只是用 Cocoa Touch 开发 iPad),我应该在 iPad 应用程序中拥有 MVC 的三个组件吗?或者只是视图和控制器?

My problem is that I don't really see how the MVC pattern fits in this. I'm working only in the front-end layer (just iPad development with Cocoa Touch), should I have the three components of MVC in the iPad application? Or just the view and controller?

我的困惑来自这样一个事实,据我所知,模型将是数据层,控制器是中间件,视图是 iPad 应用程序,但我觉得我必须在前端层.

My confusion comes from the fact that, as far as I understand the model would be the data layer, the controller the middleware and the view the iPad application but I feel I have to have some kind of representation of the model in the front-end layer.

提前致谢.

推荐答案

在对 MVC 模式进行了更多工作并阅读了许多参考资料后,其中大部分来自 SO 中的问题,我想我可以给出这样的答案:

After working a little bit more with the MVC pattern and reading many references, most of them from questions here in SO I think I can give an answer like this:

MVC 模式是应用程序组件之间关注点的逻辑分离.三层架构实现了数据、应用程序处理和表示之间关注点的分离,但它也意味着物理分离,因为它本质上是一个服务器-客户端架构.

The MVC pattern is a logical separation of concerns between the components of an application. The 3-tier architecture achieves separation of concerns between the Data, the Application processing, and the Presentation but it also implies a physical separation since it is in essence a server-client architecture.

这两种技术可以同时使用,因为它们可以被视为互补.

Both techniques can be used simultaneously since they can be seen as complementary.

由于 MVC 模式是一种逻辑分离,因此模型的不同部分很可能位于不同的物理位置.控制器也是如此,您可以在移动设备和服务器中拥有不同的控制器部分.您的所有视图都在设备中.

Since the MVC pattern is a logical separation it is quite possible to have different parts of the Model in different physical locations. The same goes for the Controller, you can have different pieces of the Controller in the Mobile Device as well as in the server. All of your views are in the device.

这里总结了如何应用这两种技术来开发服务器-客户端移动应用程序

Here's a summary of how the two techniques can be applied for developing a Server-client Mobile Application

模型

模型是您的数据和修改它的规则,这意味着您的模型的一部分位于应用程序处理层.数据可以是本地的,即存储在设备中,这意味着它位于展示层,或者它可以是远程的,例如在数据库中,以及所有代表展示层中的中间对象>数据层.

The Model is your data and the rules to modify it, that means that part of your model is in the Application processing tier. The data can be local, i.e., stored in the device which means it is in the Presentation tier or it could be remote such as in a DB and all the intermediate objects that represent which are in the Data tier.

查看

视图位于演示层.这是设备上的实际用户界面.

The View is in the Presentation tier. This is the actual User Interface that lives on the device.

控制器

控制器也可以物理分布在客户端和服务器中.这是从模型接收通知并更新视图或处理来自视图的事件并相应地使用模型的所有代码.这会将其置于应用程序处理层.

The Controller can also be distributed physically in the client and the server. This is all the code that either receives notifications from the Model and updates the View or processes events from the View and uses the Model accordingly. This puts it in the Application processing tier.

这篇关于MVC多层移动应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆