0

Builder design pattern has four principle include concrete builder and builder. What is the difference between concrete builder and builder?

Gamsh
  • 545
  • 4
  • 21

1 Answers1

0

I preusume you are referring to this picture (borrowed from Wikipedia):

builder pattern

Builder would just be the interface (meaning no implementation) and ConcreteBuilder is the implemenation of that interface. ConcreteBuilder would handle the creation of other objects

Example:

// Builder interface
public interface ICarBuilder
{
    void SetColour(string colour); // no implementation
}

// ConcreteBuilder implementation
public class CarBuilder: ICarBuilder
{
    private Car _car;

    public CarBuilder()
    {
        this._car = new Car();
    }

    // implementation
    public void SetColour(string colour)
    {
        this._car.Colour = colour;
    }
}
ivpavici
  • 1,117
  • 2
  • 19
  • 30