Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
419 views
in Technique[技术] by (71.8m points)

ipad - MVC multi-tier mobile application

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:

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

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.

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?

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.

Thanks in advance.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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:

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.

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

Model

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.

View

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

Controller

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...