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