The process of MVC and media presentation and the process of MVC media presentation

Source: Internet
Author: User

The process of MVC and media presentation and the process of MVC media presentation
What is MVC?

The full name of MVC is Model View Controller, short for model-view-controller. It is a Model of software design, organize Code by means of separation of business logic, data, and interface display, and integrate the business logic into a component to improve and personalize the custom interface and user interaction, you do not need to rewrite the business logic.

MVC)



After reading the MVC definition and illustration above, I have a preliminary understanding of MVC, especially the Stanford courseware. But in the actual development process, it seems that the MVC standard is getting farther and farther away.

I have also read iOS projects written by some of my friends. I have talked about MVC before, but it is not so good in the project. I write a project myself. In theory, I understand the MVC mode. But I still think that some places are not in place when I write code.

Especially C (we regard UIViewController as C, and there are other explanations for C on the Internet. Sometimes there are thousands of lines of code in C (not to say that code is too many to comply with MVC). C has done a lot of M-related tasks, and at the same time has done a lot of things that V wants to do.

I have read a DEMO written by the author of AFNetworking over the past few days. You can download it on github. Every step is very thoughtful. The connection between M and C is very good, and the connection between V and C is very good.

For MVC, let me talk about my understanding. In other words, the matchmaker says there is no process. M-> man, V-> woman, C-> matchmaker.

C (matchmaker) wants to introduce M (man) to a girlfriend V (Woman). C is a bridge that plays a docking role. M and V are two people who do not know each other and cannot communicate directly.

The media process is like this.: C said to M, what gifts do you want to prepare for girls when they first meet girls?

At this time, M certainly won't say, this little thing, you are still in trouble, please buy it yourself, it is estimated that the matchmaker is angry, this is certainly not a success. (When writing code, do not let C do M)

This must be done by M, and M shopping is the process of processing data. How can I buy things? How much? How to bargain? This is what M is going to do. The final result is that M buys a gift, and the gift is the object produced by the Model in the programming process.

I have bought a gift, M does not know V, and I certainly do not know how to give it to V. Therefore, the role of C is shown at this time. M wants to buy the gift (Object) hand it to C and ask C to help send it to V.

In this way, V thought it was good to get a gift and used it by himself.

Recall this process: C initiates a request to buy a gift. After M knows it, he will execute it and finally buy a gift. M. C. Give the gift to V. A complete request data shows the data process.

Although a little vulgar, there is still some truth.

If the time permits later, I will explain the DEMO written by the author of AFNetworking. Let's see what MVC is like in a project.

My public account iOS development: iOSDevTip

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.