Front-end engineering - Should the front-end mvc Model and Control be written in two separate .js files?
大家讲道理
大家讲道理 2017-05-16 17:05:27
0
2
435

There are some confusions about front-end MVC:
Model: writing logic
Control registers and controls page node events, and implements page loading performance

So, in the development of large projects, should Model and Control be written in two separate .js files, or should they be implemented in one js, as long as the main v and M are separated?
If it is divided into control.js and model.js, will there be more page requests?

Please give me some help

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(2)
大家讲道理

Should Model and Controller be written in two separate .js files?

Yes! Separation is for a better encounter!

Model is a collection of data operation methods, and Controller is responsible for calling Model methods and responding to View.
The characteristic of large projects is that data flow is large and complex, and they are not separated. Data operation methods are interspersed in Controller (coupling), so There is no overall control over the operation of page data, and it is difficult to maintain and reuse. Separately, the Model only exposes methods. At this time, the Model can be regarded as a machine for producing data. When you call the corresponding methods and parameters in the Controller, it will return the corresponding data to you. The inside of the method is transparent to the Controller (decoupling). . Model is also easy to maintain and reuse, and even the requested URL can be separated and maintained separately.

Will that increase page requests?

Front-end engineering will inevitably mention building tools, so it can be packaged together with the help of tools.

Reluctant answer, no code, please point out any errors :)

漂亮男人

@kraaas has already answered, no more to say.

When Model and Controller rise to concepts, what does it matter if they are divided or not? When the code is read by the machine, what does it matter whether it is divided or not? The problem is that the program is written for people to read, not for the machine to read. Therefore, it is convenient to read it as it is. Obviously separation is a kind of Better choice.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template