Category:Design Pattern

  • Behavior type: Xi Interpreter mode


    What is the interpreter mode Interpreter is a behavioral design pattern, which defines a language for the analysis object, defines the grammatical representation of the language, and then designs a parser to interpret the sentences in the language. In other words, use the way of compiling language to analyze the examples in the application. This […]

  • Structural design mode of detailed design mode — adapter and decorator


    Structural design mode Creative design pattern is mainly to solve the problem of creating objects, while structural design pattern is to solve the problem of using existing objects. Adapter mode The adapter mode is easy to understand because it is very common in our daily life, such as headphone conversion cable, charger adapter, socket, etc. […]

  • Creating patterns for detailed explanation of design patterns — single example, prototype and factory


    catalogue What is a design pattern Create mode Singleton pattern Prototype pattern Factory pattern Sinple factory pattern Factory method pattern Abstract factory Plant model summary I believe that as a program development, we have more or less contacted and even used design patterns, and we are even familiar with the concepts of some design patterns. […]

  • Introduction to 23 design patterns – overview of design patterns and seven principles


    Purpose of design pattern Make the program have better Code reusability (compile once, run everywhere [manual dog head]) Readability (worrying about irreplaceable) Scalability (convenient when adding new functions) Reliability (new functions have no impact on old functions) High cohesion, low coupling Seven principles of design pattern Principle of design mode: the principle to be followed […]

  • Introduction to 23 design modes — single case mode


    Singleton modeSome methods are adopted to make the software run:Only one instance object can exist in a classAnd this class can only provide one method to get an instance. classification: Hungry Han style Static constant mode Static code block mode Lazy style Normal mode, thread unsafe Synchronization method, thread safety Synchronous code block mode, thread […]

  • [design mode] singleton pattern


    Lazy style public class Singleton { private static Singleton instance; private Singleton() {}; public static synchronized Singleton getInstance() { if (instance == null) { instance = new Singleton(); } return instance; } } Initialize when calling for the first time;Synchronized locking ensures thread safety; Hungry Han style public class Singleton { private static Singleton instance […]

  • Policy mode and template method mode


    1. Strategy mode Strategy pattern is a behavior design pattern, which allows you to define a series of algorithms and put each algorithm into a separate class, so that the objects of the algorithm can be replaced with each other. Use the policy pattern when you have many similar classes that are only slightly different […]

  • Design pattern learning notes


    Author:Grey Original address:Design pattern learning notes UML and code UML diagram code Seven principles of software design Design principles One sentence induction objective Opening and closing principle It is open to extension and closed to modification Reduce new risks caused by maintenance Dependency Inversion Principle High level should not rely on low level It is […]

  • Implementation of singleton mode


    Take notes on learning singleton mode: Singleton is to ensure that there is only one instance of this class. In fact, two requirements are required to realize completely closed singleton (external cannot be new): Global access: a global static variable of this type is required. Each time you get an instance, you must judge whether […]

  • Domain Driven Design – from anemia model to congestion model


    background Domain model objects are only used to store application data. The business logic is located in the service layer and manages the data of domain objects. In the service layer, each entity of the application corresponds to a service class. It’s convenient for everyone to start the project, especially when it’s just a small […]

  • Solid principle of software design pattern


    Solid principle of software design pattern By: guest granting QQ: 1033553122 #Single responsibility principle (SRP) Definition: any software module is only responsible for a certain type of actors Note: in most cases, the “software module” here can be simply defined as a source code file, a class, a group of closely related functions and data […]

  • Object oriented design principle (solid principle)


    1、 Single responsibility The principle of single function is also called the principle of single responsibility. In short, a class should have only one reason for its change. Its central idea is high cohesion and low coupling in the principle of object-oriented design. When more than one reason causes a class to be modified, try […]