The sequence of JS design pattern

Source: Internet
Author: User

I recently read 3 books on design patterns, Head first design patterns,learning Javascript design Patterns, and the way to pick up a few years of English.

We all know an old question: what are the benefits of object-oriented? Reusable, scalable, easy to maintain, flexible. I write a program in an object-oriented language (such as C #), and my code certainly doesn't automatically get the above benefits, depending on how I write it. How to write reusable, extensible, maintainable and flexible code, Daniel has already summed up the following design principles:

  • Seperate what changes from what stays the same
  • Program to a interface, not an implementation
  • Favor composition over inheritance
  • Strive for loosely coupled designs between objects that interact
  • Classes should is open for extension, but close to modification
  • Talk your immediate friends
  • A class should has only one reason to change

If you only use a word to summarize the design principles, then it must be the first one, package changes. After all, change is "enemy", it is unavoidable, it drives us to burn the brain to accumulate strong code to pit it.

For this reason, Daniel has given us a "weapon", a variety of design patterns, to solve some aspect of a particular type of problem or problem. Design pattern is not a specific solution, it is more like a recognized template, we use this template to solve the problem. In the face of different situations, choose the right design mode, and appropriate use, decided the good or bad, is my current goal:)

The sequence of JS design pattern

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.