Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Under what circumstances do you use Builder mode

Shulou Source: shulou.com Published: 2022-06-01 03:42:19 10月04日 Update

Today, the editor will share with you the relevant knowledge points about the use of Builder mode under what circumstances, the content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article.

Applicability

Use Builder mode in the following situations

When the algorithm for creating complex objects should be independent of the components of the object and how they are assembled.

When the construction process must allow different representations of the constructed object.

In general, the process of creating a complex object can always be split into part of the algorithm (or step) and part of the actual generated artifact. Whether we want independent algorithms or alternative representations, what we do is separate the algorithm from the generated artifacts, which is the Builder pattern.

To put it simply, you can open whatever you want. The result of splitting the algorithm from the process of generating components is that both ends can be changed.

structure

Author's point of view

Compared with the term Client,Director, it emphasizes the meaning of command. In other words, Builder can only do specific things, and it is up to Director to decide what to do.

The class diagram of each design pattern has a core part, and the core of this class diagram includes Builder and ConcreteBuilder. Because once the role of Builder is decided, there must be a role to direct the work of Builder, whether it is called Director or not.

These are all the contents of the article "when to use Builder mode". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.

Tags: Patterns algorithms objects that is knowledge articles parts situations components generation different complex content core role process command independent large generally speaking Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Docker Apple NVidia macOS