Builder
GoF variant with Director orchestrating calls to the builder.
#When to use it
When you have reusable construction recipes (e.g., "PDF report", "Markdown report") and you want to encapsulate them.
public interface IReportBuilder
{
void AddTitle(string t);
void AddSection(string body);
Report GetResult();
}
public class ReportDirector
{
public void BuildExecutiveSummary(IReportBuilder b)
{
b.AddTitle("Executive Summary");
b.AddSection("Quarterly KPIs...");
b.AddSection("Risks...");
}
}When NOT to apply it
When you only have one "recipe": the director is superfluous.
#creational #director