Skip to content

tanerkahraman/CSharpDesignPatterns

 
 

Repository files navigation

Builder Design Pattern

What is Builder Pattern?

Builder pattern builds a complex object by using a step by step approach. Builder interface defines the steps to build the final object. This builder is independent of the objects creation process. A class that is known as Director, controls the object creation process.

Moreover, builder pattern describes a way to separate an object from its construction. The same construction method can create a different representation of the object.

Usage

The Builder pattern is a well-known pattern in C# world. It’s especially useful when you need to create an object with lots of possible configuration options.

Identification

The Builder pattern can be recognized in a class, which has a single creation method and several methods to configure the resulting object. Builder methods often support chaining (for example, someBuilder.setValueA(1).setValueB(2).create()).

Participants

** Builder ** - This is an interface which is used to define all the steps to create a product

** ConcreteBuilder ** - This is a class which implements the Builder interface to create a complex product.

** Product ** - This is a class which defines the parts of the complex object which are to be generated by the builder pattern.

** Director ** - This is a class which is used to construct an object using the Builder interface.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%