Methods for selecting design patterns: 1. Consider how design patterns solve design problems; 2. Browse the intent part of the pattern; 3. Research how patterns relate to each other; 4. Research patterns with similar purposes; 5. Examine the reasons for redesign; 6. Consider what is variable in the design.
There are more than 20 design patterns for you to choose from in GOF design patterns. It may be difficult to find a pattern that targets a specific design problem, especially It's when you're faced with a new set of patterns that you're not very familiar with yet. Here are a few different ways to help you discover design patterns that fit the problem at hand:
Consider how design patterns solve design problems. Section 1.6 discusses how design patterns help you find the right objects, determine the granularity of objects, specify object interfaces, and several other ways design patterns solve design problems. Referring to these discussions will help you find the right model.
The intent part of the browse mode. Section 1.4 lists the intent sections of all schemas in the directory. Read through the intent of each pattern and identify the pattern or patterns that are relevant to your problem. You can use the classification methods shown in Table 1-1 to narrow the scope of your search.
Study how patterns relate to each other. Figure 1-1 graphically shows the relationship between design patterns. Studying these relationships can guide you to the appropriate pattern or group of patterns.
Study patterns with similar purposes. There are three chapters in the pattern classification description part, one chapter introduces creational patterns, one chapter introduces structural patterns, and one chapter introduces behavioral patterns. Each chapter begins with an introductory evaluation of the pattern and ends with a subsection of comparison and contrast. These subsections give you insight into the commonalities and differences between patterns that serve similar purposes.
Check out the reasons for the redesign. Take a look at the various causes of redesign discussed starting with the section "Design should support change" and see if your problem is related to them, and then identify patterns that can help you avoid these causes of redesign. .
Consider what is variable in your design. This approach is the opposite of focusing on what caused the redesign. It's not about thinking about what will force your design to change, but about what changes you want without necessitating a redesign. The main one is the concept of encapsulating changes, which is a theme of many design patterns. Table 1-2 lists the aspects of design patterns that allow you to change them independently without incurring a redesign.
Recommended tutorial: "PHP"
The above is the detailed content of How to choose a design pattern?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Zend Studio 13.0.1
Powerful PHP integrated development environment

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),
