Excerpts from JavaScript Design Patterns (Continuous Updates …)


1. Object-oriented design encourages behavior to be distributed among fine-grained objects. If an object has too many responsibilities, it is equivalent to coupling these responsibilities together.

2. Static languages have determined the type of variables at compile time, while dynamic languages have variable types only after variables are assigned a certain value at runtime

3. dake typing: If it walks like a duck and barks like a duck, then it is a duck

4. Isolate the unchanging place and encapsulate the changeable part, which gives us the ability to expand the program. The program looks to be growing and conforms to the open-closed principle, giving consideration to elegance and safety.

5. Polymorphism is the most important technology in object-oriented programming

6. “what to do” and “how to do” can be separated.

7. Encapsulation: The stable part and the easily changeable part in the system are separated by the change mode of encapsulation. In the evolution process of the system, we only need to replace the easily changeable part.

8. singleton pattern: Ensure that a class has only one instance and provide a global access node to access it

9. Strategic mode: Strategic mode uses combination, delegation, polymorphism and other technologies and ideas to avoid multiple conditional selection statements and perfectly supports the open and closed principle

10. Iterator pattern refers to providing a method to sequentially access elements in an aggregate object without exposing the internal representation of the object