OkHttp source code analysis (builder mode, responsibility chain mode, main process)
Before analyzing the core processes of OkHttp and the core classes, let's clarify two concepts: one is the builder mode used by OkHttpClient and Request when they are created; The other is the interceptor mode responsible for response processing;
Analysis of builder mode of OkHttpClient/Request
Basic concepts
The builder (also known as the b ...
Posted by mass on Sun, 20 Feb 2022 16:10:10 +0100
Java design pattern (seven principles and singleton pattern)
1. Overview of Java design patterns
1.1 purpose and importance of design mode
(1) In software engineering, design pattern is a solution to the common (recurring) problems in software design.
(2) Code reusability, readability, scalability and reliability are the characteristics of high cohesion and low coupling.
1.2 seven principles of d ...
Posted by lipun4u on Sun, 20 Feb 2022 13:58:55 +0100
Design mode - factory mode
1, Pizza order
1. Create pizza
Abstract class pizza
//abstract class
public abstract class Pizza {
protected String name;
public abstract void prepare();
public void bake(){
System.out.println(name + "baking");
}
public void cut(){
System.out.println(name + "cutting");
}
public void box(){ ...
Posted by kuma on Sun, 20 Feb 2022 13:32:04 +0100
[OC learning notes] learn about GCD threads
1, Learn some basic knowledge
(1) Queue:
Queue queues are divided into the following types:
1. Global queue:
dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
2. Main queue:
dispatch_get_main_queue()
3. User created serial queue:
dispatch_queue_create("com.yuna.com", DISPATCH_QUEUE_SERIAL/NULL);
4. User created parallel ...
Posted by Miichael on Sun, 20 Feb 2022 09:53:30 +0100
. Net design pattern responsibility chain pattern
definition
The responsibility chain model is a model of "handling" events in a hierarchical process, which may be a little vague, For example: suppose I have a restaurant in which there are three roles of "apprentice, chef and chef". When customers come to the restaurant for dinner, they first hand over the dishes to be coo ...
Posted by promovi on Sun, 20 Feb 2022 09:20:05 +0100
Android Window series - window and decorview
summary
Window is a very common concept in android. Common knowledge points such as Activity, Dialog and Toast are inseparable from window. Therefore, the author arranges the knowledge related to the next window, hoping to help the readers in need.
window official description
The description of window in the source code of window is as follo ...
Posted by xzilla on Sun, 20 Feb 2022 05:07:01 +0100
Strategy design pattern
Application of strategy design pattern in spring source code
Use of policy design patterns
Combined with my own learning, I have some understanding of the strategy mode. First of all, the use background, in short, is used in scenarios with multiple strategies. This seems to be nonsense. Take a simple example
Let's simulate the parsing logic ...
Posted by rcorlew on Sat, 19 Feb 2022 22:20:00 +0100
3. Single case design mode
3.1 introduction
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).
3.2 eight ways of single case design mode
1) Hungry Han formula (static con ...
Posted by lorne17 on Sat, 19 Feb 2022 18:23:36 +0100
[single instance mode, multi instance mode, enumeration, factory mode]
day15 [single instance mode, multi instance mode, enumeration, factory mode]
Today's goal
Singleton mode ----- > must master
Hungry Han style single caseLazy single column Multi case mode ----- > must masterEnumeration ----- > must master
Define enumerationUse enumeration Factory mode ----- > must masterlombok plugin
Chapte ...
Posted by Slashscape on Sat, 19 Feb 2022 16:37:01 +0100
[design mode] agent mode
Full analysis of 23 design patterns (implemented in JAVA).
Introduction:
In Proxy Pattern, one class represents the functions of another class. This type of design pattern belongs to structural pattern.
In proxy mode, we create objects with existing objects to provide functional interfaces to the outside world.
Intent:
Provide a proxy ...
Posted by nafetski on Sat, 19 Feb 2022 16:24:23 +0100