Java Design Mode - Command Pattern
I. Introduction
The 23 design patterns are roughly divided into three main categories:
There are five (creation mode): factory method mode, abstract factory mode, single case mode, prototype mode, builder mode.
Seven (structural mode): adapter mode, decorator mode, agent mode, appearance mode, bridging mode, combination mode, share mode.
El ...
Posted by delorian on Tue, 14 Dec 2021 19:05:36 +0100
Decorator Mode of Design Mode
Decorator Mode of Design Mode
Decorator mode: Dynamically decorate an object with additional functionality.
1. What is the decorator mode?
Decorator mode is to dynamically decorate an object with additional functionality. To extend functionality, the decorator provides a more resilient alternative than inheritance and is more flexibl ...
Posted by gkostenarov on Tue, 14 Dec 2021 18:34:21 +0100
Factory design pattern and abstract factory design pattern
Factory design mode
1. Definition
Define an interface for creating objects and let subclasses decide which class to instantiate. Factory Method delays the instantiation of a class to subclasses—— Design patterns GoF
2. Code implementation
Code background: implement an interface to export data, allowing customers to choose t ...
Posted by smonkcaptain on Tue, 14 Dec 2021 11:56:58 +0100
Implementation of okhttp3- source code analysis interceptor chain
Interceptor chain should be one of the core of okhttp framework.
Responsibility chain model
The implementation of okhttp request Interceptor is a typical responsibility Chain mode, which generally requires the Interceptor class to implement the same interface. There is an Interceptor interface in okhttp. Both the default Interceptor and our c ...
Posted by Megienos on Sat, 11 Dec 2021 08:09:04 +0100
Design mode [5] - prototype mode
Start with a picture and write the restDesign pattern article collection: http://aphysia.cn/categories/...prefaceStudents who have come into contact with Spring or Springboot may know that beans are singleton by default, that is, they share the same object globally. Different objects will not be used because of different requests. We will not d ...
Posted by talkster5 on Sat, 11 Dec 2021 03:23:22 +0100
One of the common design patterns -- responsibility chain pattern
preface
In real life, it is a common scene that an event needs to be processed by multiple objects. For example, purchase approval process, leave process, etc. When the company's employees ask for leave, the leaders who can approve the leave include department heads, deputy general managers, general managers, etc., but the number of days e ...
Posted by miles_rich on Fri, 10 Dec 2021 12:29:18 +0100
Design pattern - abstract factory pattern
1. Overview of abstract factory patternAn abstract factory is the factory of a factory. If you abstract a factory into a product, its factory is an abstract factory.Factory mode is used to produce products, and abstract factory is used to produce factories.(1) ApplicationThe same product family (category) contains multiple products (subclasses) ...
Posted by bow-viper1 on Wed, 08 Dec 2021 19:28:20 +0100
Sharing element mode of design mode
What is the meta model
Sharing yuan, a shared element, what is sharing, is to share things and put them in one place for others to enjoy. However, in the program, we can temporarily understand this element as various objects and classes, and put them into an array to facilitate unified management and call. It's a bit like the registration mode ...
Posted by Rithiur on Wed, 08 Dec 2021 12:05:07 +0100
Serialization destroys singleton mode and how to prevent it
Serialization introduction
Serializable introduction
If the singleton class implements the Serializable serialization interface, it may be attacked by serialization to destroy the singleton pattern.
public class Singleton implements Serializable {
private static final long serialVersionUID = 1L;
private static Singleton singleton ...
Posted by maplist on Wed, 08 Dec 2021 10:17:02 +0100
Understanding and Flexible Application of Open-Close Principle
The Open and Close Principle is probably the most difficult to understand, master, and useful principle in SOLID.The reason why this principle is difficult to understand is that such questions as, "What kind of code changes are defined as extensions"? What kind of code changes are defined as modifications? How can you satisfy or viola ...
Posted by balsdorf on Tue, 07 Dec 2021 18:33:53 +0100