set up Meter mode (Design pattern) It's a set that's been used over and over again 、 Most people know that 、 Catalogued 、 Summary of code design experience . Design patterns are used for reusable code 、 Make code easier to understand 、 Guarantee agent Code reliability . without doubt , Design patterns win more than others and systems , Design patterns make coding really Engineering , Design patterns are the foundation of software engineering , It's like bricks and stones in a building . Reasonable use in the project Design patterns can perfectly solve many problems , Each pattern has its own principle in the present , Each pattern describes a recurring problem around us , And the core solution to the problem programme , That's why it can be widely used .

One 、 Classification of design patterns

Generally speaking, design patterns are divided into three categories :

Create pattern , Five kinds in total : Factory method model 、 Abstract factory pattern 、 The singleton pattern 、 Builder pattern 、 Archetypal model .

Structural mode , There are seven kinds of : Adapter pattern 、 Decorator mode 、 The proxy pattern 、 Appearance mode 、 Bridging mode 、 Portfolio model 、 The flyweight pattern .

Behavioral patterns , There are eleven kinds of : The strategy pattern 、 Template method pattern 、 Observer mode 、 Iterative subpattern 、 The chain of responsibility model 、 Command mode 、 Memo mode 、 The state pattern 、 Visitor mode 、 Intermediary model 、 Interpreter mode .

In fact, there are two kinds : And hair mode and thread pool mode . Describe as a whole with a picture :

Two 、 Six principles of design patterns

1、 Opening and closing principle (Open Close Principle)

The principle of opening and closing means Open to expansion , Turn off for changes . When the program needs to be extended , You can't change the old code , Achieve a hot plug effect . So a word summary is : In order to make the program extensible , Easy to maintain and upgrade . I want to do that , We need to use interfaces and abstract classes , We'll talk about this later in the design .

2、 Richter substitution principle (Liskov Substitution Principle)

in The principle of substitution (Liskov Substitution Principle LSP) One of the basic principles of object-oriented design . The Richter substitution principle says , Any place where a base class can appear , Subclasses must appear . LSP Is the cornerstone of inheritance and reuse , Only when the derived class can replace the base class , When the function of the software unit is not affected , Base classes are truly reusable , And derived classes can add new behaviors on the basis of base classes . in The principle of substitution is right “ open - close ” A supplement to the principle . Realization “ open - close ” The key step of principle is abstraction . And the inheritance relation of base class and subclass is the concrete realization of abstraction , So the principle of Riemannian substitution is to realize The specification of abstract concrete steps .—— From Baidu Encyclopedias

3、 Dependence Inversion Principle (Dependence Inversion Principle)

This is the basis of the opening and closing principle , The specific content : Programming interfaces , It depends on the abstract and not on the concrete .

4、 Interface isolation principle (Interface Segregation Principle)

This principle means : Use multiple isolated interfaces , Better than using a single interface . It also means reducing the coupling between classes , From here we can see that , In fact, design pattern is a software design idea , Start with a large software architecture , For the convenience of upgrading and maintenance . So many times in the above : Reduce dependence , To reduce the coupling .

5、 Dimitar's law ( Least known principle )(Demeter Principle)

Why is the principle of least knowledge , That is to say : An entity should interact with other entities as little as possible , Make the system function module relative independence .

6、 Synthetic multiplexing principle (Composite Reuse Principle)

The principle is to use composition as much as possible / Way of aggregation , Instead of using inheritance .

Design patterns (Design Patterns—— The foundation of reusable object-oriented software

  1. 《 Design patterns : The foundation of reusable object-oriented software 》【PDF】 download

    < Design patterns : The foundation of reusable object-oriented software >[PDF] Download link : https://u253469.pipipan.com/fs/253469-230382288 Content introduction < Design patterns : Repeatable ...

  2. Java Design patterns (Design Patterns)—— The foundation of reusable object-oriented software

    Design patterns (Design Patterns) Design patterns (Design pattern) It's a set that's been used over and over again . Most people know that . Catalogued . Summary of code design experience . Design patterns are used for reusable code . Make the code easier for him ...

  3. Chapter one introduction --《 Design patterns - The foundation of reusable object-oriented software 》Erich Gamma

    Chapter one introduction This chapter is mainly to let us understand what design patterns are for , Pattern classification , How design patterns solve design problems and several common methods of software reuse in object-oriented design . 1. What is design pattern ? Personal understanding generalizes , Design patterns are abstractions of a class of problems ...

  4. Cloud design patterns -Design patterns for microservices

    Cloud design patterns https://azure.microsoft.com/zh-cn/blog/design-patterns-for-microservices/ https://www.cnblogs. ...

  5. Design patterns can be reused as object creation patterns of object-oriented software design basis —ABSTRACT FACTORY( Abstract factory )

    Intention Provides an interface for creating a series of related or interdependent objects , Without specifying their specific classes . Applicability It can be used in the following situations Abstract Factory Pattern • A system should be independent of its product creation . When combining and expressing . • One ...

  6. Design patterns (Design Patterns) A brief explanation of

    The birth and definition of pattern Pattern (Pattern) It started in construction, not software ( Write it down in a small book --) The father of patterns -- Director of the center for environmental structure, University of California, USA Christopher Alexander Doctor ; Pattern : -C ...

  7. JAVA Design patterns (DESIGN PATTERNS IN JAVA) Reading summary The first 1 Partial interface mode —— The first 4 Chapter appearance (Facade) Pattern

    The appearance pattern is like a toolkit , A class corresponds to a function . The intent of the facade pattern is to provide an interface to the subsystem , Easy to use . The example given in the book is to draw the flight path of a dud , The design of the initial class is like this , Look at the picture below , ShowFlight class ...

  8. Java Design patterns (Design Patterns In Java) Reading summary —— The first 1 Chapter The introduction

    Why patterns are needed Patterns are ways of doing things , It's about achieving the goal , Methods of grinding technology . Popular point theory , Pattern is an effective method or skill to solve a problem in a certain industry . Why design patterns are needed In order to improve the level of code , It's the code that makes it simple and easy to use . A pattern is an idea , ...

  9. 【 Design pattern series 】 And OO Seven principles of object-oriented design

    1   summary This chapter describes the seven principles of object-oriented design , The seven principles are divided into : Principle of single responsibility . Opening and closing principle . Richter's principle of substitution . The principle of Dependence Inversion . Interface isolation principle . synthesis / Principle of aggregation and reuse . Dimitar's law . 2   seven OO Object oriented design 2.1 A single ...

Random recommendation

  1. android Of the four components ---Service

    service Service life cycle --- 1 Start the life cycle of services Complete life cycle :onCreate()-->onStartCommand()-->onDestroy() *  Opening service :onCreate ...

  2. python The way -Day7

    Programming paradigm Programming is Program member Use specific syntax + data structure + Algorithmic code that tells a computer how to perform a task , A program is a set of instructions written by a programmer to get the result of a task , All roads lead to Rome , The way to accomplish a task ...

  3. mysql note 03 Query performance optimization

    Query performance optimization 1. Why is the query speed slow ? 1). If you think of a query as a task , So it's made up of a series of subtasks , Each subtask takes a certain amount of time . If you want to optimize the query , Actually optimize its subtasks , Or eliminate some of the subtasks , Or less ...

  4. totolink Of n200r The price of routing in excellence network and Jingdong network

    totolink Of n200r The price of routing in excellence network and Jingdong network , When a friend needs help to buy totolink Of n200r The routing , I always buy electronic products in Jingdong , I've been shopping on excellence before , So today I also went to see excellence online n200r The price of ...

  5. 【 turn 】Storm Detailed explanation of parallelism

    1.Storm The concept of parallelism Storm The cluster has many nodes , By type nimbus( Master node ).supervisor( From the node ), stay conf/storm.yaml There is a supervisor, There are multiple slots ...

  6. JavaWeb The internationalization of (17/4/8)

      The disadvantages of internationalization : Because the words are different , So the problem of typesetting is just as serious , It's usually more clear to write a website again , quick 1: You need to get the browser language from the browser (Accept-Language) 2: utilize locale obtain ...

  7. Linux Network management

    One . Network foundation 1)ISO/OSI Introduction to the seven layer model ISO: International Organization for Standardization OSI: Open Systems Interconnection Model IOS: Apple operating system ( In a computer network ,IOS It's the Internet operating system , It is an operation and maintenance system developed by Cisco for its network equipment ) ...

  8. send Asp.net Core It also supports output Json/Xml

    We know Asp.net Core Yes, the output is Json Format . It also supports the output of xml Format . As long as we have the right configuration . And in Request Specify the correct Accept, According to different Header To output different formats . front ...

  9. python The fifth chapter : file -- Xiaobai blog

    File operations , After the operation of the file, be sure to remember close # read , The default is rt( The way text is read ),rb The pattern is read in bytes # The file path can be used 3 In the form of f = open(r'C:\Users\fengzi\Des ...

  10. Test website nginx Do you support tls1.2 The command line

    [root@~]# nmap --script ssl-enum-ciphers -p 443 www. Want to rest .cn Starting Nmap 5.51 ( http://nmap.org ) at ...