C + + singleton mode and thread safety

C + + singleton mode and thread safety The simplest singleton mode can be // single thread safe version class Singleton { public: static Singleton* GetInstance(int x = 0) { if (instance_ == NULL) { instance_ = new Singleton(x); } return instance_; } void Print() { ...

Added by sheen.andola on Sat, 05 Mar 2022 11:48:04 +0200

Abstract Factory Pattern

1, Definition Abstract Factory Pattern: one of the innovative patterns, which provides an interface to create a series of related or interdependent objects without specifying their specific classes. 2, UML class diagram 3, Roles and responsibilities Abstract Product: it is the interface that defines the Product. It is the supertype of the ...

Added by tarlejh on Sat, 05 Mar 2022 09:33:07 +0200

Strategy pattern of Java design pattern

Strategy pattern of Java design pattern Prepare project questions (1) There are all kinds of ducks (such as wild duck, Peking duck, water duck, etc. ducks have all kinds of behaviors, such as barking, flying, etc.) (2) Display duck informationBasic introduction to strategy mode (1) In Strategy Pattern, algorithm families (policy groups) are de ...

Added by codepoet on Sat, 05 Mar 2022 04:56:54 +0200

java design pattern_ Decorator mode

1 Overview The purpose of decorator mode is to enhance the performance of classes. Inheritance can also enhance the functionality of classes. 2 examples (easy to observe and understand the decoration mode) The Writer class is a class that writes files. It has three subclasses: TxtWriter, MP3Writer and AVIWriter The standard for writing fil ...

Added by siric on Sat, 05 Mar 2022 01:16:39 +0200

C++---stack & queue & adapter mode & priority queue & imitation function

catalogue 1, Container adapter 1. What is an adapter? 2, Introduction and use of stack and queue 1. Introduction to stack 2. Use of stack 3. Introduction to queue 4. Use of queue 3, deque's brief introduction (understanding) 1. Principle of deque 2. Defects of deque 4, Simulation of stack and queue 1. Simulation Implementation of st ...

Added by jasonhardwick on Fri, 04 Mar 2022 22:03:33 +0200

[single instance mode, multi instance mode, factory mode and enumeration]

1. Single case design mode Function: single instance mode can ensure that there is only one instance of the class applying this mode in the system. That is, an object can only have one instantiated object. Implementation steps 1. Privatize the construction method of the class so that it cannot instantiate the object outside the class th ...

Added by hrichman on Fri, 04 Mar 2022 12:05:41 +0200

[design pattern] - Proxy Pattern

Proxy Pattern 1 Introduction: Agency mode is also called entrustment mode, which is a structural design mode. 2 Definition: provide a proxy for other objects to control access to this object. 3 usage scenarios: (1) do not want to directly access an object; (2) when it is impossible or difficult to access an object, it can be accessed indirec ...

Added by DJ Digital Gem on Thu, 03 Mar 2022 23:55:44 +0200

Factory mode of design mode

The design principle is a summary of some experience guiding our code design, that is, "mental method"; Object oriented is our "weapon"; Design pattern is "move". Based on mental skill, use weapon moves to deal with complex programming problems. Cousin: brother, I read the news today that the EU has expanded s ...

Added by prinzcy on Thu, 03 Mar 2022 16:29:53 +0200

Byte beating technology sorting: how to be efficient and practical Kotlin? Complimentary course + question bank

preface If a worker wants to do well, he must sharpen his tools first! In modern IT, every Android programmer needs the best tools to improve their skills and efficiency. In the brutal competitive industry of Android application development, only good programmers can survive. You need to show your customers the best technology and capabilities ...

Added by xluminex on Thu, 03 Mar 2022 14:03:13 +0200

Study notes on factory mode of 23 design modes

What is the factory model? As the name suggests, factory is to create products. According to whether the products are specific products or specific factories, it can be divided into simple factory mode and factory method mode. According to the degree of abstraction of factories, it can be divided into factory method mode and abstract factory m ...

Added by metuin on Tue, 01 Mar 2022 09:16:14 +0200