YY口试,对MVC框架M层的理解,求指导
YY面试,对MVC框架M层的理解,求指导
根据我的理解,平时用来处理数据的方法,我把它封装成类,以后遇到同样的数据处理我就调用这个类,这个类属于M层,处理数据。
面试官问我:
我们抓取网页有这么几步
1.根据URL抓取网页
2.正则表达式处理html元素
3.将抓取到的内容存入数据库
以上这三部哪一步处于M层?
我觉得三步都属于啊。
求大家指导我的理解是否有错,错在哪里,拜托了~
如果上面三步哪一步不是M层,那它属于MVC的哪一层??
------解决思路----------------------
1 是控制层 3是处理数据层 我是这么理解
------解决思路----------------------
第三步,m是数据处理层,当然你应用逻辑也可以写在m层,只不过很不规范。
正确的mvc架构应该让c层尽可能少的处理数据逻辑,而让m来处理,否则mvc的最大优点--代码模块化的优势就体现不出来了。
仅供参考!
------解决思路----------------------
MVC架构根本就没有准确定义,面试官水平不够或者故弄玄虚吧。
V是用户视角
C是业务视角
M是功能视角
三者本来就是一起合作完成任何一个功能的。抓取网页的话,对资源的请求一般写在M里。
正则表达式分析HTML这个,C和M都说得过去。在M里写好方法,C里调用是个比较好的结构。
数据库操作肯定是M,因为很多框架里,M就剩下访问数据库了。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

Guide to Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.

Guide to HTML Input Placeholder. Here we discuss the Examples of HTML Input Placeholder along with the codes and outputs.
