23 design patterns
How to use design patterns
Why use design patterns?
Write code, write interface, write class, write method
What is the role of designing with design patterns?
Guide and specify how to write code, how to write interfaces, classes, and methods
Why use design patterns?
The demand will change, the code will change, in order to cope with the change, in order to facilitate the expansion in the future, so as to respond to the change with the same, the unchanged is the change
How to start using design patterns?
1: Clarify reality
2: Distinguish between change and unchanged
3: Find out how it will change
4: How can users isolate this change
Different ways of change correspond to different design patterns
. The embodiment of design :
how to define interfaces, classes, and methods
How to start using:
find out the changes, separate the changes and the unchanged,
isolate and encapsulate the changed parts, so that other parts are not affected by it
23 design patterns
Creation mode
These design patterns provide a way to hide the creation logic while creating an object, instead of using the new operator to directly instantiate the object, which makes the program more flexible in judging which objects need to be created for a given instance
- The Java design pattern that Nuwa created people to cause thinking: factory pattern
- There is only one Java design pattern for you in this world: singleton pattern
- Installed the computer and thought about the Java design pattern: the builder pattern
- Monkey King’s body magic uses Java design pattern: prototype pattern
Structural model
These design patterns focus on the combination of classes and objects. The concept of inheritance is used to combine interfaces and define the way in which combined objects obtain new functions.
- Refers to the Java design pattern of square drawing circle: Adapter pattern
- The reincarnation of Bajie turned out to be a Java design pattern: bridge pattern
- The old monk tells the story to the young monk, which triggered the Java design pattern: combination pattern
- Look at Java Design Patterns from Monkey King’s 72 Changes: Decorator Pattern
- Java design pattern triggered by a security guard: Appearance pattern
- A whim of the milk tea shop started the Java design pattern: Flyweight pattern
- Teacher Tony takes you to see the Java design pattern: proxy mode
Behavioral model
These design patterns pay special attention to communication between objects
- Drumming Chuanhua associates with the Java design pattern: the chain of responsibility pattern
- The Jade Emperor's Legend of the Monkey King Going to Heaven, the Java Design Pattern of Making a Harass in Heaven: Command Mode
- Looking at the Java design pattern from China’s entry into WTO: the intermediary pattern
- The story of Guanyin Ganquan Living Tree turned out to be a Java design pattern: memo pattern
- what? The goddess sent a circle of friends, come and watch the Java design pattern: observer pattern
- The Java design pattern of reverie triggered by the chime of Zeng Houyi: State Pattern
- Zhuge Liang's tips and tricks turned out to be the famous Java design pattern: strategy pattern
- From the ninety-nine and eighty-one difficulties of learning from the West, look at the Java design pattern: the template method pattern
- Java design pattern triggered by computer monopoly system: visitor pattern
- A brief introduction to Java design patterns: interpreter mode
- A simple understanding of Java design patterns: iterator pattern (reproduced)
- The forgotten design pattern-the empty object pattern (reproduced)
to sum up
Please remember three points:
- Find the change
- interface
- combination
- One
- Multiple
- combination