Detailed explanation of factory mode
Generally, the factory pattern is divided into three more subdivided types: simple factory, factory method and abstract factory. However, in GoF's book design patterns, it regards simple factory patterns as a special case of factory method patterns, so factory patterns are only divided into factory methods and abstract factories. In the rookie ...
Added by EricTRocks on Thu, 28 Oct 2021 14:23:12 +0300
Singleton design pattern
1, Basic introduction to singleton mode
The so-called class singleton design pattern is to take certain methods to ensure that there can only be one object instance for a class in the whole software system, and the class only provides a method to obtain its object instance (static method).
2, There are eight ways of singleton mode
Hu ...
Added by bough on Sun, 24 Oct 2021 10:20:38 +0300
Observer model of design pattern
1. Brief overview
The observer pattern defines the one to many relationship between objects, that is, when the state of an object changes, it will tell other dependent objects to update the state accordingly.In the observer mode, the object that sends the status change notification is called the subject, and the object that receives and re ...
Added by phpfreak101 on Sat, 23 Oct 2021 19:28:32 +0300
Design mode - singleton mode
Lazy singleton mode
Code implementation:
public class SingletonMode {
private static SingletonMode instance=null;
//Privatize the construction method to prevent external instantiation
private SingletonMode(){}
public static SingletonMode getInstance(){
if(instance==null){
instance =new SingletonMode();//Ca ...
Added by Ju-Pao on Wed, 20 Oct 2021 05:03:58 +0300
2.1 Creative Design Mode
1. Knowledge Points
BasicsDesign PrinciplesTemplate MethodObserver modePolicy Mode
2. Recommended Books
Design Patterns - Fundamentals of Reusable Object-Oriented SoftwareReconstructing and Models
3. Foundation
Design Mode A design pattern is a validated solution to a specific problem that occurs repeatedly in a particular environment ...
Added by Cugel on Tue, 19 Oct 2021 19:59:00 +0300
10, Adapter mode
0. Ma Xian inspirational
Have a dream, even if it is far away.
1. General
If you travel to European countries, their sockets are shown on the far left of the figure below, which is the European standard. The plug we use is shown on the far right in the figure below. Therefore, our laptops and mobile phones cannot be directly charged loca ...
Added by James25 on Sat, 16 Oct 2021 10:40:21 +0300
Design mode 2 status mode
definition
State mode: when the internal state of an object changes, it is allowed to change its behavior. The object looks like it has changed its class. And strategy mode are twins. It mainly solves the problem when the conditional expression controlling the state transition of an object is too complex. That is, the state judgment logic ...
Added by james_kirk on Tue, 12 Oct 2021 08:24:46 +0300
Ali interview review: what are the four Java references and what are their differences?
We all know that in JVM garbage collection, GC can judge whether the object instance or data in the heap is garbage by reference counting method and reachability algorithm.
Whether the number of references of an object is determined by the reference counting algorithm, whether the reference chain of an object is reachable by the root search al ...
Added by Morbius on Tue, 12 Oct 2021 02:53:47 +0300
Design mode - singleton mode
catalogue
1. Background:
2. Definition of singleton mode:
3. Lazy man - several problems in the single case development process:
three point one Single thread single instance mode creation
three point two Test whether the single instance mode can maintain the definition in the case of multithreading
three ...
Added by mckintosh18 on Sun, 10 Oct 2021 17:43:37 +0300
Shen's Learning Notes-Design Mode-Bridge Mode
Schematic diagram
Bridge schema definition: divides abstraction and behavior into separate but dynamic combinations.
To summarize object-oriented, there are actually two sentences: one is Coupling, the other is Cohesion. The goal of the object system is to maximize the Cohesion within the system modules and minimize the modules. Coupling be ...
Added by cowfish on Fri, 08 Oct 2021 19:24:24 +0300