Let's take a look at the 23 design patterns of Java design ideas

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
Insert picture description here
. 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

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.

Behavioral model

These design patterns pay special attention to communication between objects

to sum up

Please remember three points:

  • Find the change
  • interface
  • combination
    • One
    • Multiple
    • combination

Guess you like

Origin blog.csdn.net/qq_34365173/article/details/108015106