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

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

问题描述

我对使用MVC模式感到有点困惑。我们有一个3层架构:数据,中间件,前端。我们正在开发一款适用于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形式显示结果

  • 用户交互(点击图标)/修改(编辑某些输入)

  • 重复...

  • consumes a JSON service
  • shows the results in some UI form
  • the user interacts (taping an icon) / modifies (editing some input)
  • repeat...

在前一个流程的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模式如何适应这一点。我只在前端层工作(只用iPad开发Cocoa Touch),我应该在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模式进行更多工作并阅读许多参考资料之后,其中大部分来自于此处的问题我认为我可以这样给出一个答案:

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模式是应用程序组件之间关注点的逻辑分离。
3层架构实现了数据,应用程序处理和演示文稿之间的关注点分离,但它也意味着物理分离,因为它本质上是服务器 - 客户端架构。

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模式是逻辑分离,因此很可能在不同的物理位置具有模型的不同部分。对于Controller来说也是如此,您可以在移动设备和服务器中拥有不同的控制器部分。您的所有观看次数都在设备中。

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

模型

模型是您的数据和修改规则,这意味着您的模型的一部分位于应用程序处理层中。数据可以是本地的,即存储在设备中,这意味着它位于 Presentation 层中,或者它可以是远程的,例如在DB中,以及表示在数据等级。

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.

控制器

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

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天全站免登陆