Builder design PatternTable of Contents:
Builder mode
Builder Pattern Implementation
Sample code
Use
Applications in the JDK
Builder modeLike factory and abstract factory design patterns, the builder design pattern is also one of the object cre
Provides a "encapsulation mechanism" to isolate changes in "parts of complex objects".In order to keep the "stable building algorithm" in the system, it does not change with the demand. ———— Builder ModeConstruction mode is the creation mode of the objectConstruction mode separates the internal representation of a product from the production process,This can be a construction process that generates product objects with different internal representatio
Using system; using system. text; using system. collections. generic; using system. LINQ; namespace builder mode {/** builder mode intent: separates the construction of a complex object from its representation, so that the same build process can create different representations. ** Builder mode advantages: 1. the builder
Java Design Pattern builder PatternThis article continues to introduce the builder modes of the 23 design patterns series.Definition: builder mode: separates the construction of a complex object from its representation, so that different representations can be created during the same construction process.Scope 1: When creating complex objects, algorithms should b
Design design Pattern C # language Description-builder (builder) mode
* This article refers to "Java and the pattern" part of the content, suitable for the design pattern of beginners.
The build pattern is the object's creation pattern. The construction pattern separates the internal representation of a product from the product's generation process, thus enabling a build process to produce a product
In Android development, non-UI threads cannot operate controls in the UI thread, that is, the UI is non-thread-safe.
As I said in the previous article:
It is non-UI secure, that is, it does not accept modification requests from non-UI threads. When we modify it through anoth
Android Studio-UI thread blocking and optimization, android-ui
When using a mobile phone, we often encounter a problem: First we get stuck, and then jump out of the program without a response, whether to close the prompt (of course, it may be that our mobile phone performance is too poor =. =) This is caused by thread blocking. Here I will introduce the UI thread
the motherboard
However, the components of each compatible machine are different. Some configurations are higher and some are lower, which is a change point. For the installation technician, he does not need to consider where these accessories come from. He just needs to assemble them together. This is a stable installation process. To separate the changed accessories from the stable process, we need to introduce the builder mode.
ExampleCode
PHP design mode-builder mode, PHP design mode
Requirements Analysis:
We received an order from BMW and Mercedes-Benz, who are responsible for defining the parts and models of the product, and we are responsible for the production and the simple description of the requirement. We need to design a design pattern for this requirement to better adapt to their needs.
First of all we need a car model class to define all the components needed, which is call
Definition Separates the construction of a complex object from its representation so that different representations can be created during the same construction process. Such a design pattern is called the builder pattern.
Applicability 1. When a complex object is created
Algorithm It should be independent from the components of the object and their assembly methods. 2. When the constructor must allow different representations of the constructed obje
The builder for the base class is definitely called in the builder of a derived class, and is gradually linked up so that the builder used by each base class can be called. The reason to do this is because the builder has a special task: to check whether the object is properly built.Let's take a look at an example that
backgroundDo not underestimate the little things on the small, want to go on a meal, it is necessary to obey the rules, step-by-step careful. I'm sure you've eaten a fast food without salt and eaten a fast food with a lot of salt. Since stir-frying is such a complicated process and must obey the rules, why not give him a death rule? If someone does not follow the rules, the corresponding alert warning will be made. This is the origin of the builder pa
PHP design mode-builder mode
The builder pattern is also called the generator pattern, and the core idea is to separate the construction of a complex object from its representation so that the same build process can create different representations, which are called builder patterns.
For example: Cars, his engine engine has a lot of brands, tires also have a v
Php design mode-builder mode, php design mode
Requirement Analysis:
We received an order from BMW and Mercedes Benz, which defines the parts and models of the product. We are responsible for production, and the requirement is simply described as follows. We need to design a design model for this requirement to better adapt to their needs.
First, we need a car model class to define all the required parts. This is called an abstract class because we may
Recently, when learning the picture loading frame glide, he was shocked by his streamlined wording. In a word, it can be done.Glide.with (mcontext). load (URL) . Centercrop () . Placeholder (r.drawable.default_img) . Crossfade ( ) . into (Mimageview); At the same time at the beginning of the year, when learning Rxjava, with a chain-style programming is very elegant. Observable . Just ("1", "2") . Subscribeon (Schedulers.io ())
First, the builder model(Builder)The factory class pattern provides the pattern of creating a single class, while the builder pattern is to centralize the various products to manage, to create composite objects, so-called composite objects that refer to a class that has different properties, in fact the builder pattern
Problems to solve:
The object I created is more complex, and the member functions inside the object represent different instances with different implementations, in other words, the same object-building process can have different representations. For example, I went to eat crossing that day, they have different packages, the package contains the same kind of, have a bowl of rice noodles, a cold dish, a drink. But the 3 of different packages are not all the same. At this point, we can use the
The builder mode is a design mode that separates the construction of a complex object from its representation so that different representations can be created during the same construction process. Next, I will introduce you to the JavaScript design mode classic builder mode through this article. if you are interested, let's study it together.
1. concepts of builder
The---builder pattern for C # Design PatternsFirst, the definition:Builder mode separates complex constructs from their representations so that the same build can produce different representations.Second, prototype mode application:In software systems, it is sometimes faced with the creation of a complex object, which is usually made up of a certain algorithm by each part of the object,or by a combination of steps, these algorithms and procedures are
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.