- It is a creational design pattern.
- It separates the construction of a complex object from its representation so that the same construction process can create different representations, depending upon the order of process steps and/or addition or deletion of a few process steps.
- Further, the steps of constructions should be independent of each other so that order of process steps can be changed. That is, the steps should not be tightly coupled.
- One possible solution is to create different processing steps or components of the products/classes and pass them as parameter to the constructor of the final product class. We can use Boolean parameters to decide which component will be used in the final product and null parameter to omit a component. But such constructor call becomes unwieldy. To overcome this, we use Builder Design Pattern.
- The products have common steps/processes/methods which are given inside abstract class or interface called Builder. These methods should be abstract and they should be overridden in the Concrete Builder classes that inherits/implements the Builder class. There are many Concrete Builder classes in BDP.
- The Director class is used in the BDP which defines the order in which to execute the building steps, while the Builder provides the implementation for those steps.
- Having a director class in your program isn’t strictly necessary. We can always call the building steps in a specific order directly from the client code. However, the director class puts various construction routines so we can reuse them across the program.
- In addition, the director class completely hides the details of product construction from the client code. The client only needs to associate a builder with a director, launch the construction with the director, and get the result from the builder.
Sunday, June 20, 2021
C# Design Pattern - Builder Design Pattern
Subscribe to:
Post Comments (Atom)
Hot Topics
-
Objectives To provide detailed information about ListBox Types of ListBox Using ListBox in VBA applications Please read the post till end...
-
Main points about class Class is a template to create objects. Class is user defined data type. Class represents a business entity. Class is...
-
JavaScript was created in 1995 by a programmer named Brendan Eich for Netscape Communications Company. Brendan Eich worked in the same comp...
No comments:
Post a Comment