series

  • Using JavaScript learning design patterns (1) | small volume of free learning
  • Using JavaScript learning design patterns (2) | small volume of free learning
  • Using JavaScript learning design patterns (3) | small volume of free learning
  • Using JavaScript learning design patterns (4) | small volume of free learning

review

Use a mind map to review the types of design patterns, divided into three types of creative, structural, behavioral, 23 design patterns.

review

(1) Object-oriented final design objectives:

  • A Scalability: With new requirements, new capabilities can be easily added to the system without affecting existing performance or introducing new defects.

  • B Flexibility: Adding new functionality code changes happen smoothly without affecting other parts.

  • C replaceable: Some code in the system can be replaced with other classes of the same interface without affecting the system.

(2) Benefits of design mode:

  • A Design patterns make it easier to reuse successful designs and architectures.
  • B Design patterns also make it easier for developers of new systems to understand their design ideas.

(3) Learning design mode has three realms (seen many times online) :

  • # 1: You learn a design pattern while thinking about where it can be used in the project I just did (knife in hand, not knife in mind)

  • 2. You have learned all the design patterns, but when you come up against a problem, you find that there are several design patterns to choose from, and you have no choice (knife in hand, knife in mind).

  • Third and last, you may have no concept of design patterns, only a few design principles in mind that you can use when you need them (the highest level of knife skills: no knife in hand, no knife in mind).

If, in accordance with the state to understand, I also just a touch to the threshold of the first heavy, actually in the learning process publish-subscribe pattern, strategy pattern and singleton pattern, I have thought of before one write a function in some projects, if I had mastered the design pattern, using the ideas of design patterns to write the code may be written better, logic and more clear. In the near future, I’m also planning to refactor some of the features from previous projects using design patterns.

Learn to use, to forget but a period of time, is not in vain to learn? .

After learning design patterns, my biggest feeling is that if you don’t learn something, you will never know where to use it.

conclusion

The following is a summary of the core principles and application practices of JavaScript design patterns, excerpted from the Gold Digger booklet.

This is the end of the design pattern journey. But for you, the real battle has just begun. The charm of design pattern is not on paper, but in practice.

Learn design patterns:

  • Read more – read source code, read materials, read good books;
  • Practice more – apply what you’ve learned to business development.

No design pattern is perfect. Design pattern, like human beings, is in the process of dynamic development. Not only the 23 design patterns proposed by GOF can be called design patterns.

As long as a solution follows design principles and solves a class of problems, it is entitled to the title of “design pattern”.

As you graduate from the design patterns booklet, I hope you will take with you not only knowledge, but also good study habits and reading habits. The most important is the courage to dig deep into theoretical knowledge and the determination to tackle technical problems. These things are not the so-called “koban” patent, but a good engineer must.

reference

  • Core principles and application practice of JavaScript design pattern
  • Common design patterns in JavaScript
  • Big talk about design patterns
  • Design Mode -W3CSchool
  • Design Mode – Novice tutorial

Original from Ninety: links to original blog posts

This article is part of the “Gold Nuggets For Free!” Event, click to view details of the event