Builder design pattern has four principle include concrete builder and builder. What is the difference between concrete builder and builder?
Asked
Active
Viewed 450 times
1 Answers
0
I preusume you are referring to this picture (borrowed from Wikipedia):
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