Recently I\'ve come across the Builder design pattern. It seems that different authors use \"Builder pattern\" to refer to different flavours, so let me describe the pattern
If you separate into Director and Builder you have documented the different responsibility of assembling a product from a set of parts (director) and the responsibility of creating the part (builder).
AddLiquid() should add cream or milk.AddChocolate() instead of AddFruits() you get a different cake.If you want this extra flexibility, I would rename to (since using baker in the builder suggests, it was the builders job of assembling the parts)
class LightBakingSteps : public BakingSteps {
public:
virtual void AddLiquids()
{
// Add milk instead of cream
}
virtual void AddDryIngredients()
{
// Add light sugar
}
...
};
class ChoclateCakeBaker : public CakeBaker {
public:
Cake Bake(BakingSteps& steps)
{
steps.AddLiquieds();
steps.AddChocolate(); // chocolate instead of fruits
return builder.getCake();
}
}