Some thoughts on front-end frame and front-end class library in web development _javascript skills

Source: Internet
Author: User

Speaking of the front frame, I was also drunk. Now go to the interview or chat with peers, the framework is not at all, the frame is very sharp.

Of course not to belittle the frame, but there is a way to kill the chicken with the feeling of a sledgehammer. Web technology exists for the business, except this is meaningless, the framework is the same. In the technology selection and architecture design, from the actual development of the website business, blindly pursue fashionable new technology, may be counterproductive, the development of the site into the rugged path. It's like a small electric dealer website with a daily PV of only hundreds of, but yell, "That's what a treasure is for," and then build an application server cluster, using Distributed file systems and distributed database systems ... A bunch of balabala to deal with high concurrency, massive data access means. I want to say, does it make sense?

The misunderstanding of the front frame's understanding

The value of the site is what it can provide users with what value, is what the site can do, but not how it is done, so the site is still very small when the site to pursue the framework of the trifles is not worth the candle. Front-end Framework Similarly, if a simple page product, the application only relies on the server to generate Web pages and views, and only need to use some simple JavaScript or jquery to make the application more interactive, then a jquery front-end class library can be, There is really no need to use some tall frame.

Of course, the framework is really useful, and the point is that we need to know when and what framework to use. Big company experience and success model is important, it is worth learning, but we can not become blindly follow. Only a profound understanding of the front-end framework, know when to use what framework to solve what problems, can be targeted, straight hit the key.

The difference between front-end frame and front-end class library

Before using frames, I think it is important to understand where the differences between class libraries (such as jquery) and frameworks (such as ANGULARJS) are.

In a nutshell, a class library solves the problem of code or module-level reuse or encapsulation of complexity, such as encapsulating a functional module that solves a complex problem into a function that provides a simple interface. Library It is a tool that provides a lot of encapsulated good methods, with and without depending on ourselves, that is, the code structure that uses and does not affect us.

The framework, however, is more about the pattern level of reuse and the specification of program organization. The pattern here is, for example, MVC, in order to decouple M and V, the complex coupling relationship is shifted from the frequently changing business code to the less frequently changing framework for internal digestion. is to provide a set of solutions for a single domain to improve development efficiency, and if we choose to use a framework, we should follow the rules set out in that framework.

The main difference is that jquery is centered on DOM manipulation, framework, and, precisely, the MVC framework, centered on models (model), and DOM operations are additional. Therefore, the goal of the model as the center is to bring a whole set of workflow changes, so that the background engineers can write the front end of the model code, the background and front-end through, interactive designers to deal with the interaction between the UI and model, UI designers can focus on, barrier-free processing of HTML source code, Submit them to the interaction engineer in the form of an interface template. This set of collaborative mechanisms can greatly improve development efficiency. Using the MVC framework makes the front-end tasks better decoupled.

Front-end MVC framework Idea

As we know, the traditional MVC pattern divides an application into a model layer, a view layer, a control layer (Controller). They play different roles in the application system, accomplishing different tasks.

Model: The data model, which is used to package data related to the business logic of the application or to process the data, which can directly access the data.

View: Views are used for purposeful display of data, and there is generally no procedural logic in the view, and the view needs to access the data model it monitors in order to implement the latest features on the view.

Controller: The controller regulates the relationship between the model and the view, which controls the process of the application, handles the event, and responds, not only to the user's behavior but also to changes in the data model. By capturing the user event, the model layer is notified of the corresponding update process, and the update and change of the model layer are notified to the view, making the view change accordingly. So the controller guarantees the consistency of the view and the model.

My understanding of the front end view is that the parts that are directly related to the elements on the page belong to view. Includes Html,css and part of the direct control of page elements of JS. You can get the data from model and display it on the page. And the change of data and request, all hand over to controller processing.

So what about controller? As the glue of model and view, controller will forward the view request to the appropriate model and update view when necessary. And controller itself can also be model of the observer, get model changes. And as controller itself, there should be no code involved in page elements.

Finally, the model, and back-end communication, Ajax requests, as well as the processing of data belong to model work. Model itself does not know who is view, who is controller. It provides only a few methods for view and controller calls, and notifies its observer view or controller of the change. Obviously, model and page elements are also decoupled.

Although there are many differences between frameworks based on the MVC model, overall, the model is responsible for preserving the data required by vier and processing logic such as read-write, update, delete, validate, transform, and so on. View is responsible for receiving and displaying the data provided by the model as well as receiving input from the user, and responding to the event, model updated timely feedback back to the user. Controller handles business logic and event logic.

Knowing and knowing the right remedy

The front-end framework and class libraries are getting richer today. Choose a pair of frame or class library is particularly important, I think there is no need to blindly follow the wind, see what frame fire on the fart to chew one weeks, and then because the project work, and after a few months after all forgotten.

So I think the important thing is to build a solid foundation, the focus is to understand the role of various libraries and frameworks, a type of framework focused on what problems to solve, and then when the project needs to use the time to read the API is the best policy.

Finally, we need to be clear about the limitations of MVC's application in front-end development, and simple projects that use the MVC framework can cause the project to become more complex. Of course, with the increasing complexity of Web front-end, the development of the front-end MVC framework, it is believed that the MVC framework will bring the efficiency leap to the front-end work in the future application software class complex products.

The above is just my front frame and class library some superficial understanding, do not like to spray, I hope you can put forward a better learning framework and class library methods. Common progress and common learning.

If there is a technical level of error also please treatise, fraught is a sin.

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.