YY interview, understanding of the MVC framework M-layer, seeking guidance

Source: Internet
Author: User
According to my understanding, usually used to deal with the data method, I encapsulate it into a class, later encountered the same data processing I call this class, this class belongs to the M layer, processing data.

The interviewer asked me:
We crawl the page with so few steps
1. Crawling Web pages based on URLs
2. Regular expressions handle HTML elements
3. Storing crawled content in the database

Which of the above three steps is on the M level?

I think three steps belong to AH.
I beg you to guide my understanding is wrong, where the fault, please ~
If the top three steps are not the M layer, which layer of MVC is it??


Reply to discussion (solution)

Personally feel that the 3rd part of the M layer.
Because the 3rd part of the database query.

Is the first step likely to belong to layer C? This depends on the definition of the project.

3 must be 12, but it doesn't count, I understand.
The first 3 is the direct operation of the database, it must be a very versatile low-level interface
2 can also count M, for the XX website to do processing, from the site of the HTML can be called
1 can still be m, nothing more than a curl crawl on the basis of 2, url as parameter

I think 1.2 belongs to the business logic layer, 3 is the data layer

Obviously 3, the operation of the data

1 is control layer 3 is processing the data layer I understand that.

Only 3 is the control layer.

The third step, M is the data processing layer, of course, your application logic can also be written on the M layer, but very nonstandard.
The right MVC architecture should allow the C layer to deal with the data logic as little as possible, and let m handle it, otherwise the greatest advantage of MVC-the advantage of code modularity is not evident.
For reference only!

The MVC architecture is not exactly defined at all, and the interviewer is not as good or as mysterious.
V is the user perspective
C is the business perspective
M is a functional perspective
The three are supposed to work together to complete any one function. When crawling Web pages, requests for resources are generally written in M.
Regular expression parsing html this, C and M are all plausible. Writing a good method in M, the C call is a good structure.
The database operation is definitely m, because in many frameworks, M is left with access to the database.

  • 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.