Home > Web Front-end > JS Tutorial > body text

Loose coupling of UI layer in web development

php中世界最好的语言
Release: 2018-06-04 10:48:55
Original
1670 people have browsed it

This time I will bring you the loose coupling of the UI layer in web development. What are the precautions when using loose coupling of the UI layer in web development? Here are practical cases, let's take a look.

In web development, the UI is defined by three layers that are isolated and interact with each other.

HTML is used to define the data and semantics of the page

CSS is used to add styles to the page and create visual features

JS is used to add behavior to the page to make it more Interactivity

Allow me to say a few words about loose coupling. When you can modify one component without changing other components, you have loose coupling. For large multi-person systems, where many people are involved in maintaining the code, loose coupling is critical to code maintainability. You absolutely want developers to not break other people's code when they modify one part of the code. When the content of each component of a large system is limited, loose coupling is achieved. Essentially, each component needs to be kept thin enough to ensure loose coupling. The less known about the components, the better it is to form the overall system.

One thing to note: components working together cannot achieve "no coupling". In all systems, components share some information to do their jobs. It's easy to understand that our goal is to ensure that changes to one component do not regularly affect other parts.

If a Web UI is loosely coupled, it is easy to debug. Problems related to text or structure can be located by searching HTML. When a style-related problem occurs, you know the problem is in the CSS. Finally, for those behavioral issues, your ability to go directly to JS to find the problem is a core part of the maintainability of web interfaces.

In the WebPage era, we advocate the three-layer separation of HTML/CSS/JS. For example, it is forbidden to use the inline attribute of the DOM to bind the listener,

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!