One design pattern per day (1)-Overview

Source: Internet
Author: User
Preface

I have summarized the design patterns recently. This article will give you an overall introduction to the design patterns.

Body 1. Definition

The design pattern is a code design solution for a specific type of problem. It is a summary of the experience in code design.

2. Role
  • Improve code reuse rate and reduce development costs and cycles
  • Improve code maintainability and scalability
  • Make the code more elegant and readable
  • Make code easier to be understood by others
3. Design Principles

The following object-oriented design principles must be observed when designing a design pattern:

  • Single Responsibility Principle(SRP): For a class, there should be only one reason for its change.
  • Principle of opening/closing(ASD): Classes, modules, and functions can be expanded, but cannot be modified.
  • Rys replacement principle(LSP): All objects that reference the base class (parent class) must be transparently used.
  • Dependency inversion principle(DIP): High-Level modules should not depend on low-level modules. Both of them should depend on abstraction. Abstraction should not depend on details, but on abstraction.
  • Dumit principles(LOD): A software entity should interact with other entities as little as possible.
  • Interface isolation principle(ISP): The dependency of one class on another class should be built on the smallest interface.
4. Design Pattern Classification

Common23TypeDesign ModeIn general, there are three categories:Creation Mode,Structural ModeAndBehavior mode.

Creation ModeFive methods: Factory method mode, abstract factory mode, Singleton mode, builder mode, and prototype mode.

Structural Mode(7 in total): adapter mode, decorator mode, proxy mode, appearance mode, bridging mode, combination mode, and meta mode.

Behavior mode(11 in total ): rule mode, template method mode, observer mode, iteration sub-mode, responsibility chain mode, command mode, memorandum mode, state mode, visitor mode, intermediary mode, interpreter mode.

Shows the three types of design patterns and their classifications:

Summary

This article gives a general introduction to the definition of design patterns. Next I will analyze several common design patterns in detail.

Welcome to the public account: the technology Stack


This account will continue to share back-end technologies, including virtual machine basics, multi-thread programming, high-performance frameworks, asynchronous, cache and messaging middleware, distributed and microservice, architecture learning and advanced learning materials and articles.

One design pattern per day (1)-Overview

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.