
🌇 Previously in Friendopia…
After the chaos of a broken LEGO city, Mr. Kohli introduced Prisha and her friends, Arijay and Nimisha, to the magical world of design patterns.
“Think of them,” he explained, “as clever tricks that help us to solve common problems.” They would begin today with one of the strongest: the Builder Pattern.
🏗️ The Wobbly Tower
In Friendopia, Prisha pointed to their tower, which was leaning to one side.
This was our highest building,” Nimisha said. “But it just collapses each time we try to add something new.”
“Everyone built it their way,” Arijay said. “No one did it the same.”
Mr. Kohli nodded. “That’s precisely why we need the Builder Pattern.”
🗼Scene 1: A Tower in Trouble
The team started at the tallest building in the city—a 3-story LEGO tower.
“It’s great-looking, but it collapses every time we add something,” said Nimisha.
“It’s because we built it too quickly,” admitted Arijay. “I put it on the top floor, then Prisha attempted to force the windows in. Nothing fits quite right.”
Mr. Kohli examined the leaning tower. “You’re building the what, but not planning the how.”
🏗️ What Is the Builder Pattern?
Mr. Kohli settled into his seat and took out his notebook.
“Through the Builder Pattern, you get a creational design pattern that makes it easy to construct complicated objects stepwise. Instead of loading everything into a constructor, you divide the construction into smaller steps.”
He turned the page. “Imagine you want to construct towers, castles, or rocket ships. They all require: A base and some floors. Roof’s Optional features (such as flags, windows, and balconies), but each of them might be slightly different. The Builder Pattern provides you with the flexibility of customization, while following the same procedure.”
Builder Pattern:
1. Start with a blueprint (Director)
2. Follow a fixed set of steps (Builder)
3. Customize pieces as needed
4. Get a fully built object (Product)
🏛️ Structure

🎯 Real-Life Analogy: Making a Sandwich
Mr. Kohli smiled. “Ever made a sandwich?”
“Oh, yes,” said Prisha. “I begin with the bread, then cheese, then sauce, and all that.”
“Exactly,” he replied. “You’re following steps: bread → filling → toppings. That’s a builder process. Every sandwich can be different, but the order of steps keeps it neat and edible.”
👩⚕️Scene 2: Meet the Roles in the Builder Pattern
Mr. Kohli distributed name tags.
🧢 Director – Nimisha: Decides what type of building to construct.
🛠️ Builder – Arijay: Knows how to construct it, step by step.
🧍♀️Client – Prisha: What would she like? (A tall tower with three stories and a red flag).
🏙️ Product – The actual tower that is constructed.
They utilized LEGO trays to depict pieces of all elements—bases, floors, windows, and flags.
🧩 Scene 3: Building with the Builder Pattern
Arijay constructed the tower piece by piece.
🔲 build_base() → Assembled using grey 4×8 pieces.
🧱 build_floors(3) → Added three colorful floors.
🚪 add_windows() → Installed windows all the way around.
🏁 add_roof(flag=True) → Added a red roof and flag on top.
Each piece fit perfectly into position. No misfits. No wobbles.
“Whoa,” said Nimisha. “That was so smooth!”
Mr. Kohli grinned. “That’s the beauty of separation. The Director decides what to build. The Builder figures out how to build it. The Client doesn’t worry about the details.”
⛩️ Structure of Tower & Bridge Creation using Builder Pattern

💻 Builder Pattern in Code (for Developers)
Mr. Kohli opened his laptop and demonstrated how the same logic works. .net.
🏙️ Product Classes
🗼Tower
public class Tower
{
private List<string> _parts = new List<string>();
public void Add(string part) => _parts.Add(part);
public void Show() => Console.WriteLine("Tower Parts: " + string.Join(", ", _parts));
}
🌉 Bridge
public class Bridge
{
private List<string> _sections = new List<string>();
public void Add(string section) => _sections.Add(section);
public void Show() => Console.WriteLine("Bridge Parts: " + string.Join(", ", _sections));
}
🔧 IBuilder (Generic Builder Interface)
public interface IBuilder<T>
{
void BuildBase();
void BuildMainStructure(int count);
void BuildExtras();
T GetResult();
}
🏢 TowerBuilder (Concrete Builder Class)
public class TowerBuilder : IBuilder<Tower>
{
private Tower _tower = new Tower();
public void BuildBase() => _tower.Add("Tower Base");
public void BuildMainStructure(int count)
{
for (int i = 1; i <= count; i++)
_tower.Add($"Tower Floor {i}");
}
public void BuildExtras() => _tower.Add("Tower Roof with Flag");
public Tower GetResult() => _tower;
}
🌉 BridgeBuilder
(Concrete Builder Class)
public class BridgeBuilder : IBuilder<Bridge>
{
private Bridge _bridge = new Bridge();
public void BuildBase() => _bridge.Add("Bridge Pillars");
public void BuildMainStructure(int count)
{
for (int i = 1; i <= count; i++)
_bridge.Add($"Bridge Span Section {i}");
}
public void BuildExtras() => _bridge.Add("Guardrails and Lights");
public Bridge GetResult() => _bridge;
}
🎬 Director class
public class Director
{
public void Construct<T>(IBuilder<T> builder, int mainStructureCount)
{
builder.BuildBase();
builder.BuildMainStructure(mainStructureCount);
builder.BuildExtras();
}
}
🧪 Client – Build and Display Different Towers
class Program
{
static void Main(string[] args)
{
var director = new Director();
// Build Tower
var towerBuilder = new TowerBuilder();
director.Construct(towerBuilder, 3);
Tower tower = towerBuilder.GetResult();
Console.WriteLine("== Tower Built ==");
tower.Show();
// Build Bridge
var bridgeBuilder = new BridgeBuilder();
director.Construct(bridgeBuilder, 4);
Bridge bridge = bridgeBuilder.GetResult();
Console.WriteLine("\n== Bridge Built ==");
bridge.Show();
}
}
Output
== Tower Built ==
Tower Parts: Tower Base, Tower Floor 1, Tower Floor 2, Tower Floor 3, Tower Roof with Flag
== Bridge Built ==
Bridge Parts: Bridge Pillars, Bridge Span Section 1, Bridge Span Section 2, Bridge Span Section 3, Bridge Span Section 4, Guardrails and Lights
For Developers and Architects:
- You can create Builder using FluentAPI.
- For a multithreaded environment, use a thread-safe approach.
✅ When to Use the Builder Pattern
Use it when:
- The object that you are creating is complicated or has to be customized.
- The construction process includes more than one step.
- You want to separate object construction from its representation.
Avoid it when:
- The object is extremely simple.
- You don’t require different configurations or parts.
- Speed and memory are paramount (since it creates additional classes).
🧠 Benefits Recap
🪜 Step-by-step build
🧩 Customizable and flexible
🧼 Cleaner, more maintainable code
🔁 Reusability for objects of various types
🏙️ Scene 4: Friendopia 2.0
By evening, the children had three towers of varying heights and colors—but all strong, well-structured, and lovely.
Prisha high-fived her friends. “Builder Pattern is like having a recipe for awesome towers!”
I can construct these types of towers all day,” said Arijay.
“Suppose now,” Mr. Kohli added, “that you could press a button and bring cars, shops, or buildings into being with one command…“
👀 “Wait,” Nimisha replied, “like a factory?”
Mr. Kohli smiled.
🔜 Coming Up Next: The Factory Pattern
Episode 3 – The LEGO Factory: One Command, Many Creations