In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article shares with you the content of a sample analysis of the web front-end look and feel pattern. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Appearance mode (Facade Pattern)
Appearance pattern is one of the most common design patterns, which provides a unified high-level interface for a group of interfaces in the subsystem, making the subsystem easier to use. In short, the design pattern is to abstract the complex logic in multiple subsystems, so as to provide a more unified, more concise, easier-to-use API. Many of our commonly used frameworks and libraries basically follow the design pattern. For example, JQuery abstracts and encapsulates complex native DOM operations and eliminates the compatibility problems between browsers, thus providing a more advanced and easier-to-use version. In fact, in our daily work, we often use appearance patterns for development, but we just don't know it.
Compatible browser event binding
Let addMyEvent = function (el, ev, fn) {if (el.addEventListener) {el.addEventListener (ev, fn, false)} else if (el.attachEvent) {el.attachEvent ('on' + ev, fn)} else {el [' on' + ev] = fn}}
Encapsulation interface
Let myEvent = {/ /... Stop: e = > {e.stopPropagation (); e.preventDefault ();}}
Scene
At the beginning of the design, we should consciously separate two different layers, such as the classic three-tier structure, and establish a facade Facade between the data access layer and the business logic layer, the business logic layer and the presentation layer.
In the development phase, subsystems often become more and more complex because of continuous refactoring and evolution. Adding appearance Facade can provide a simple interface and reduce the dependence between them.
When maintaining a large legacy system, it may already be difficult to maintain, so it is very appropriate to use appearance Facade to develop an appearance Facade class for the department system, which provides a clearer interface for poorly designed and highly complex legacy code, allowing the new system to interact with Facade objects, and Facade to interact with all the complex work of legacy code.
Advantages
Reduce system interdependence.
Increase flexibility.
Improved security
Shortcoming
Do not comply with the principle of opening and closing, if it is troublesome to change things, it is not appropriate to inherit and rewrite.
Thank you for reading! This is the end of this article on "sample analysis of web front-end appearance pattern". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 230
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.