Purpose: Convert the interface of a class to another interface that the client wants. The adapter pattern enables classes to work together that would otherwise not work together due to incompatible interfaces.
Hypothetical scenario: In the past, the mobile phone had a memory card, the mobile phone user put the data in the memor ...
Posted by phpnew on Fri, 13 May 2022 14:20:27 +0300
The behavior model is responsible for efficient communication and responsibility assignment between objects.
Policy pattern: encapsulates a set of algorithms into a series of objects. By passing these objects, you can flexibly change the function of the program. For example: Java util. Comparator#compare ...
Posted by gargoylemusic on Fri, 13 May 2022 12:42:04 +0300
Introduction and implementation of prototype Manager
Prototype manager is a factory that stores multiple prototype objects in a collection for clients to use. It is specifically responsible for cloning objects. A collection is defined to store prototype objects. If a clone of a prototype object is needed, it can be obtained by copying the corre ...
Posted by drfate on Thu, 12 May 2022 10:52:12 +0300
This section talks about the Builder Pattern.
In some cases, a large class needs to rely on other small classes to jointly fulfill a requirement, just as a complete mobile phone needs small parts such as CPU and screen.
The builder pattern is used to deal with this composition process, which is defined as: refers to the separation of the constr ...
Posted by dmayo2 on Thu, 12 May 2022 03:53:43 +0300
1, Delegation mode
In the delegate mode, the delegate mode is similar to the delegate mode. In the delegate mode, the delegate mode can be regarded as a result of the delegate mode.
give an example:
The Boss assigns tasks to the project manager. The project manager will distribute work tasks to each employee according to the actual situatio ...
Posted by Unseeeen on Wed, 11 May 2022 21:44:57 +0300
1: Object oriented thought
1. Characteristics of object-oriented thought
1)Conform to the habits of thought and behavior in the real world!
2)Let's turn the executor into the commander(The role has changed!)
3)Simplify complex things!
2. Object oriented design principles in Java
You need to constantly create objects,Use object,Com ...
Posted by hemantraijain on Wed, 11 May 2022 16:50:24 +0300
In order to make the approval process of the purchase order more flexible and realize the chain transmission and processing of the purchase order, the developers of Sunny use the chain of responsibility model to realize the hierarchical approval of the purchase order. The basic structure is shown in the figure:
In the figure ...
Posted by Catharsis on Wed, 11 May 2022 10:24:14 +0300
Observer Pattern Observer Pattern is an object behavior pattern. When a one-to-many dependency relationship between objects is defined, whenever the state of an object changes, its related dependent objects are notified and automatically updated. Observe Provider mode is also known as Publish-Subscribe Publish-Subscribe mode, ...
Posted by MARIOPARTY53 on Wed, 11 May 2022 08:20:49 +0300
Also known as: Visitor Design Pattern
Intention: Visitor pattern is a behavior design pattern that can isolate the algorithm from the object it works on.
1, Code example
For example, consider a shopping cart in which we can add different types of items (elements). When we click the checkout button, it will calculate the total amount to be p ...
Posted by Neoraven456 on Mon, 09 May 2022 04:02:27 +0300