The six types of singleton mode, how to ensure thread safety, reflection safety and serialization safety, are finally clear this time
1, Foreword
The singleton mode belongs to the creation mode, which ensures that there is only one instance of the singleton class in the system. It can avoid frequent creation of an object and reduce memory consumption to a certain extent.
This article will explain various implementation types of singleton classes, and explain the measures to ...
Posted by grudz on Wed, 06 Oct 2021 09:10:38 -0700
Design pattern - abstract factory pattern
preface
The same kind is called the same level, that is, the factory method mode only considers the production of products of the same level, but in real life, many factories are comprehensive factories that can produce multi-level (type) products. For example, mobile phone factories produce both mobile phones and computers. The abstract f ...
Posted by philvia on Wed, 06 Oct 2021 08:11:18 -0700
Design Mode-06 (Prototype Mode)
Prototype mode
* Personal Blog: www.xiaobeigua.icu
1.1 Overview
Use a created instance as a prototype and copy the prototype object to create a new object that is the same as the prototype object.
1.2 Structure
The prototype pattern contains the following roles:
Abstract prototype class: A clone() method that spe ...
Posted by yogicasey on Sun, 03 Oct 2021 10:03:17 -0700
How GPUImage works
This article mainly explains how the GPUImage bottom layer is rendered. The GPUImage bottom layer uses OPENGL to manipulate the GPU to realize screen display
Because there are very few online OpenGL actual combat materials, the official documents can not explain some methods clearly, so as to avoid the majority of students from climbing the pi ...
Posted by phoolster on Sat, 02 Oct 2021 15:57:17 -0700
Chapter 0 of Design Mode for Station B - Introduction of Design Mode
The root cause of complex software design
: Change
Objectives of software design:
Reuse!
Solutions to complexity:
1,
decompose
(Not easy to reuse)
Divide and conquer, break big problems into many small problems, and complex problems into many simple problems.
2. Abstract (easy to reuse)
Because you cannot ...
Posted by bonaparte on Sat, 02 Oct 2021 10:18:24 -0700
Design mode 12 single example mode
1. Motivation:
When there is only one or more, the performance will be reduced;How to bypass conventional constructors and provide a mechanism to ensure that a class has only one instance?This is the responsibility of the designer, not the user.
2. Single thread
class Singleton{
private:
Singleton();
Singleton(const Singleton& other);
p ...
Posted by forumsudhir on Fri, 01 Oct 2021 11:03:51 -0700
Opening and closing principles of 23 design modes
Open Closed Principle
Basic introduction:
The opening and closing principle is the most basic and important design principle in programming
A software entity such as class, module and function should be open to extension (for the provider) and closed to modification (for the user). Build the framework with abstraction and extend the detail ...
Posted by markthien on Thu, 30 Sep 2021 18:39:24 -0700
Why doesn't Compose have layout nesting problems?
Author: Ricardo mjiang
preface
Students who have done layout performance optimization know that in order to optimize the interface loading speed, the layout level should be reduced as much as possible. This is mainly because the increase of layout level may lead to the exponential growth of measurement time. Composition does not have this p ...
Posted by SteveMT on Thu, 30 Sep 2021 13:49:09 -0700
Java interceptor filter pattern
Java interceptor filter pattern
Intercepting Filter Pattern is used to pre / post process the request or response of the application. Define filters and apply them to requests before passing them to the actual target application. The filter can do authentication / authorization / logging, or track requests, and then pass the requests to the co ...
Posted by parawizard on Wed, 29 Sep 2021 21:55:14 -0700
Observer model of design pattern
When there is a one to many relationship between objects, the Observer Pattern is used. For example, when an object is modified, it will automatically notify the objects that depend on it. Observer mode belongs to behavioral mode.
Intent: defines a one to many dependency between objects. When the state of an object changes, all objects that ...
Posted by Fawkman on Wed, 29 Sep 2021 17:30:11 -0700