Design principles and design patterns of *javascript development

Source: Internet
Author: User

Design principles (7 types):

There are so many principles that guide us in the design and development of our programs because there is an unknown change in our program. In order to embrace this unknown change at the lowest cost, our predecessors summed up so many principles.

① Yagni Principles
You aren ' t gonna need it
Do not write code that you do not need

②kiss Principles
Keep it simple and stupid
Code keeping brief and expressive
Naming of semantic words, annotations, variables or methods, reduced nesting

③dry Principles
Don ' t Repeat yourself
Encapsulation of modules
Improve the reuse rate of code to reduce the difficulty of testing convenient later iteration and maintenance

④high Cohesion Low coupling
Cohesion Poly-Low coupling
Cohesion: the relationship between different components within a component
Coupling: The relationship between different components

⑤SRP (single responsibility principle)
Single Responsibility Principle

⑥OCP (open closed principle)
Opening and closing principle

⑦LCP Minimum Knowledge principle

Design Patterns (23 types), divided into 3 major categories:

The principle of design, how can I use this principle in the actual project? Design Patterns are designed to solve these problems.

Design Patterns are a set of reusable, most known, categorized purposes, code design experience Summary. Design patterns are used in order to reuse code, make code easier for others to understand, and ensure code reliability. There is no doubt that design patterns in others in the system are multi-win, design patterns so that code is truly engineering, design patterns are the cornerstone of software engineering, like a block of bricks and tiles in the building. The rational use of design patterns in the project can solve many problems perfectly, each of which has corresponding principles in the present, each of which describes a recurring problem around us, and the core solution of the problem, which is why it can be widely used . We have learned that these design patterns can make us more aware of the importance of design principles, and design principles can also help us to remember and flexibly apply various design patterns.

① created mode, total 5 kinds: Factory method mode, abstract Factory mode, singleton mode, builder mode, prototype mode.

② structure mode, a total of 7 kinds: adapter mode, adorner mode, proxy mode, appearance mode, bridge mode, combined mode, enjoy the meta-mode.

③ Behavioral Model, a total of 11 kinds: policy mode, template method mode, observer mode, iterative sub-mode, responsibility chain mode, Command mode, Memo mode, state mode, visitor mode, mediator mode, interpreter mode.

Reprint please indicate the source of the article

Design principles and design patterns of *javascript development

Related Article

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.