Comprehensive and thorough analysis of factory method mode
This article is excerpted from "design patterns should be learned this way"1. Application scenario of factory method modeThe factory method mode is mainly applicable to the following application scenarios.(1) Creating objects requires a lot of repetitive code.(2) The client (application layer) does not depend on the details of how pro ...
Posted by NCllns on Thu, 11 Nov 2021 07:34:37 +0100
You think the delegation model is mysterious, but you use it every day
This article is excerpted from "design patterns should be learned this way"
1. Use delegation mode to simulate task allocation scenarios
We use code to simulate the business scenario where the boss assigns tasks to employees. First, create the IEmployee employee interface.
public interface IEmployee {
void doing(String task) ...
Posted by Amit Rathi on Tue, 09 Nov 2021 11:53:54 +0100
24, Visitor mode
0. Ma Xian inspirational
Any restriction starts from your heart.
1. General
definition:
Encapsulates some operations that act on each element in a data structure. It can define new operations that act on these elements without changing the data structure.
2. Structure
The visitor pattern contains the following main roles:
Abstract Vi ...
Posted by asd on Wed, 03 Nov 2021 03:49:20 +0100
21, Observer mode
0. Ma Xian inspirational
It's not difficult to endure those hard days, because I know it will get better.
1. General
definition:
Also known as Publish/Subscribe mode, it defines a one to many dependency that allows multiple observer objects to listen to a topic object at the same time. When the state of the subject object changes, it wi ...
Posted by toyfruit on Tue, 02 Nov 2021 19:59:54 +0100
12 interface isolation principle - object oriented design principle
Opening and closing,Richter substitution,Dependency inversion,Single responsibility,Interface isolation,Dimitt,Synthetic multiplexing
In addition to the principles of opening and closing, Richter substitution, dependency inversion and single responsibility, the principles of object-oriented design also include the principles of interface isola ...
Posted by sparks on Tue, 02 Nov 2021 04:35:30 +0100
Design mode of hand roll - agent mode
1, Introduction to agent mode
1.1 definitions
Proxy is a design pattern that provides another access to the target object; That is to access the target object through the proxy object. The advantage of this is that additional function operations can be enhanced on the basis of the implementation of the target object, that is, the funct ...
Posted by Patch^ on Mon, 01 Nov 2021 14:00:25 +0100
Design patterns should be learned this way
1. Factory mode
1. Concept
Factory Pattern is one of the most commonly used design patterns in Java. This type of design pattern is a creation pattern, which provides the best way to create objects.
In factory mode, when creating objects, we do not expose the creation logic to the client, and point to the newly created objects by usi ...
Posted by gunslinger008 on Sat, 30 Oct 2021 13:23:26 +0200
Six principles of design mode
1. Single principle
Too many lines of code, functions or attributes in the class will affect the readability and maintainability of the code, so we need to consider splitting the class;Classes depend on too many other classes, or depend on too many other classes, which does not conform to the design idea of high cohesion and low coupling, so w ...
Posted by fooDigi on Sat, 30 Oct 2021 02:51:15 +0200
Creative mode - Factory mode (simple factory mode, factory method mode, abstract factory mode)
Statement: This blog refers to the Chinese Language C website: C Language Chinese Network Connection
The main record is learning the following: 1. Simple Factory Mode II. Factory Method Mode 3. Abstract Factory Mode Each main point consists of the following two parts: (1) Basic concepts and model structure (including some NOUN explanations, mo ...
Posted by revez2002 on Thu, 28 Oct 2021 19:37:13 +0200
Hand roll design mode - enjoy yuan mode
1, Introduction to Xiangyuan mode
1.1 definitions
Definition of Flyweight pattern: using sharing technology to effectively support the reuse of a large number of fine-grained objects. By sharing existing objects, it can greatly reduce the number of objects to be created and avoid the overhead of a large number of similar classes, so as ...
Posted by simpjd on Wed, 27 Oct 2021 10:56:41 +0200