Interview Q&A

Master technical and career interviews with structured answers—short definition, real examples, pitfalls, and how to answer in 60–90 seconds.

4608 total questions 4508 technical 100 career & HR 4272 from PDF library

Showing 1451–1475 of 3281

Career & HR topics

By tech stack

Popular tracks

Mid PDF
UI Event Handling: ○ In GUI systems, UI components (like buttons or text boxes) can be considered observers that listen to changes or events (like button clicks) from

Short answer: user interface. Visual Diagram: +------------------+ +-------------------+ | NewsPublisher |-------| NewsSubscriber | | (Subject) | | (Observer) | +------------------+ +-------------------+ | | | Subscribe/…

GoF Patterns Read answer
Mid PDF
Usage (Client Code): ● In the Main method, a NewsPublisher is created, along with two subscribers: Alice?

Short answer: And Bob. The subscribers are subscribed to the publisher. When the publisher sends out a notification (Notify()), all subscribers are automatically notified and updated with the latest news. class Program {…

GoF Patterns Read answer
Mid PDF
Decorator (CoffeeDecorator): ○ The CoffeeDecorator class is an abstract class that implements the ICoffee interface and holds a reference to an ICoffee object. This class

Short answer: llows us to add additional behavior to the coffee object, but we don't modify the base class (SimpleCoffee). Explain a bit more public abstract class CoffeeDecorator : ICoffee { protected ICoffee _coffee; p…

GoF Patterns Read answer
Mid PDF
UI Event Handling:?

Short answer: In GUI systems, UI components (like buttons or text boxes) can be considered observers that listen to changes or events (like button clicks) from a user interface. Explain a bit more Visual Diagram: +------…

GoF Patterns Read answer
Mid PDF
Colleague (User):?

Short answer: The User class represents a user in the chat application. Explain a bit more Each user has a name and a reference to the mediator. When a user wants to send a message, they call Send() on the mediator, whic…

GoF Patterns Read answer
Mid PDF
Uniform Access:?

Short answer: The Iterator Pattern provides a consistent and uniform way to access elements of the collection, regardless of the underlying structure of the collection. Real-Time Use Case Examples: Say this in the interv…

GoF Patterns Read answer
Mid PDF
Concrete Iterator (ProductIterator):?

Short answer: The ProductIterator class is the concrete iterator that implements the IIterator<Product> interface. It holds a reference to the collection (ProductCollection) and provides the logic for iterating ove…

GoF Patterns Read answer
Mid PDF
Non-terminal Expression (Add):?

Short answer: The Add class represents a non-terminal expression that combines two other expressions (leftExpression and rightExpression). The Interpret method evaluates both sides of the expression and returns their sum…

GoF Patterns Read answer
Mid PDF
Usage (Main Program):?

Short answer: In the client code, we create a CharacterFactory instance to manage the characters. We then iterate over the text "Hello World", requesting a Character object for each character. The flyweight obj…

GoF Patterns Read answer
Mid PDF
Creator (LoggerFactory):?

Short answer: This is an abstract class that declares the CreateLogger method, which is intended to return an ILogger instance. The actual instantiation is delegated to subclasses. public abstract class LoggerFactory Exa…

GoF Patterns Read answer
Mid PDF
Decorator (CoffeeDecorator):?

Short answer: The CoffeeDecorator class is an abstract class that implements the ICoffee interface and holds a reference to an ICoffee object. This class allows us to add additional behavior to the coffee object, but we…

GoF Patterns Read answer
Mid PDF
Composite (Directory):?

Short answer: The Directory class represents the composite component in the tree structure. It can contain files or other directories. The Add() method is used to add components (both files and directories) to the direct…

GoF Patterns Read answer
Mid PDF
Receiver (Document):?

Short answer: The Document class represents the receiver of the command. It contains the actual operations for adding and removing text from the document. The AddText and RemoveText methods manipulate the internal conten…

GoF Patterns Read answer
Mid PDF
Log Level Enum:?

Short answer: The LogLevel enum defines the different types of log messages (e.g., Info, Error). public enum LogLevel { Info, Error } Say this in the interview Define — one clear sentence (the short answer above). Exampl…

GoF Patterns Read answer
Mid PDF
Concrete Builder (MargheritaPizzaBuilder):?

Short answer: The MargheritaPizzaBuilder is a concrete implementation of the IPizzaBuilder interface. It builds a specific type of pizza (Margherita in this case) by setting the dough, sauce, and adding toppings. The Bui…

GoF Patterns Read answer
Mid PDF
Concrete Implementations:?

Short answer: The DrawingAPI1 and DrawingAPI2 are concrete implementations of the IDrawingAPI interface. These classes implement the specific drawing logic for rendering circles, but they could use different libraries or…

GoF Patterns Read answer
Mid PDF
Abstract Product Interfaces (Button and Checkbox):?

Short answer: The IButton and ICheckbox interfaces define the general contract for products. Each concrete product (e.g., WindowsButton, MacButton) will implement the Render method to display platform-specific UI element…

GoF Patterns Read answer
Mid PDF
○ The Add class acts as a composite expression that adds the results of two?

Short answer: other expressions. It leverages the recursive nature of the Interpreter Pattern to evaluate complex expressions. Real-world example (ShopNest) Use a GoF pattern in ShopNest only when it removes duplication…

GoF Patterns Read answer
Mid PDF
How It Works:?

Short answer: How It Works:? is a common interview topic in Gang of Four Patterns. Give a clear definition, then one concrete example. Real-world example (ShopNest) Use a GoF pattern in ShopNest only when it removes dupl…

GoF Patterns Read answer
Mid PDF
Invoker (TextEditor): ○ The TextEditor class is the invoker that invokes commands. It holds a stack of commands (_commandHistory) and is responsible for executing

Short answer: And undoing commands. When a command is executed, it’s pushed onto the stack. The Undo() method pops the last executed command and undoes its ction. public class TextEditor { private readonly Stack<IComm…

GoF Patterns Read answer
Mid PDF
Director (PizzaDirector): ○ The PizzaDirector class orchestrates the pizza building process. It uses a builder to construct a specific type of pizza (like Margherita) by calling the

Short answer: ppropriate methods on the builder. It then returns the final product. public class PizzaDirector { private readonly IPizzaBuilder _builder; public PizzaDirector(IPizzaBuilder builder) => _builder = build…

GoF Patterns Read answer
Mid PDF
Usage: ○ In the Program class, you create an instance of Adaptee and then wrap it with an Adapter. The adapter.Request() call works seamlessly with the incompatible SpecificRequest() method, allowing the system to interact with the third-party library as if it were designed for the current system interface. class Program { static void Main() {

Short answer: daptee adaptee = new Adaptee(); ITarget adapter = new Adapter(adaptee); dapter.Request(); // Outputs: Specific request from daptee. Explain a bit more } } daptee adaptee = new Adaptee(); ITarget adapter = n…

GoF Patterns Read answer
Mid PDF
Product Class:?

Short answer: The Product class represents an individual product with a property Name. This is the item that we will iterate over in the collection. public class Product Example code { public string Name { get; } public…

GoF Patterns Read answer
Mid PDF
Usage (Client Code):?

Short answer: In the Main method, we create two Number expressions (5 and 10) and then create an Add expression to combine them. Finally, we evaluate the expression by calling Interpret on the addExpression object. class…

GoF Patterns Read answer
Mid PDF
Concrete Creators (FileLoggerFactory and ConsoleLoggerFactory):?

Short answer: These subclasses of LoggerFactory override the CreateLogger method to return the appropriate logger type (either FileLogger or ConsoleLogger). FileLoggerFactory: public class FileLoggerFactory : LoggerFacto…

GoF Patterns Read answer

Gang of Four Patterns Design Patterns in C# · GoF Patterns

Short answer: user interface. Visual Diagram: +------------------+ +-------------------+ | NewsPublisher |-------| NewsSubscriber | | (Subject) | | (Observer) | +------------------+ +-------------------+ | | | Subscribe/Unsubscribe | Update v v +------------------+ +-------------------+ | NewsPublisher | | NewsSubscriber | | (Subject) |-------| (Observer)… |……… +------------------+ +-------------------+ Conclusion: The Observer…

Explain a bit more

Pattern is a powerful and flexible design pattern for building systems where objects need to be notified of changes to another object's state.

Real-world example (ShopNest)

When order status changes, observers update email, SMS, and analytics without the Order class knowing each one.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Gang of Four Patterns Design Patterns in C# · GoF Patterns

Short answer: And Bob. The subscribers are subscribed to the publisher. When the publisher sends out a notification (Notify()), all subscribers are automatically notified and updated with the latest news. class Program { static void Main() { var publisher = new NewsPublisher(); var subscriber1 = new NewsSubscriber("Alice"); var subscriber2 = new… nd Bob. The subscribers…… are subscribed to the publisher. When the publisher sends…

Explain a bit more

out a notification (Notify()), all subscribers are automatically notified and updated with the latest news. class Program { static void Main() { var publisher = new NewsPublisher(); var subscriber1 = new NewsSubscriber("Alice"); var subscriber2 = new NewsSubscriber("Bob"); publisher.Subscribe(subscriber1); publisher.Subscribe(subscriber2); publisher.Notify("Breaking News: Observer Pattern in C#!"); } } Output: lice received news: Breaking News: Observer Pattern in C#! Bob received news: Breaking News: Observer Pattern in C#! How It Works: And Bob. The subscribers are subscribed to the publisher. When the publisher sends out a…

Real-world example (ShopNest)

When order status changes, observers update email, SMS, and analytics without the Order class knowing each one.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Gang of Four Patterns Design Patterns in C# · GoF Patterns

Short answer: llows us to add additional behavior to the coffee object, but we don't modify the base class (SimpleCoffee).

Explain a bit more

public abstract class CoffeeDecorator : ICoffee { protected ICoffee _coffee; protected CoffeeDecorator(ICoffee coffee) => _coffee = coffee; public virtual double Cost() => _coffee.Cost(); public virtual string Description() => _coffee.Description(); } llows us to add additional behavior to the coffee object, but we don't modify the base class (SimpleCoffee). public abstract class CoffeeDecorator : ICoffee { protected ICoffee _coffee; protected CoffeeDecorator(ICoffee coffee) => _coffee = coffee; public virtual double Cost() => _coffee.Cost(); public virtual string Description() => _coffee.Description(); }

Real-world example (ShopNest)

Logging and caching decorators wrap IProductRepository so core SQL code stays clean.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Gang of Four Patterns Design Patterns in C# · GoF Patterns

Short answer: In GUI systems, UI components (like buttons or text boxes) can be considered observers that listen to changes or events (like button clicks) from a user interface.

Explain a bit more

Visual Diagram: +------------------+ +-------------------+ | NewsPublisher |-------| NewsSubscriber | | (Subject) | | (Observer) | +------------------+ +-------------------+ | | | Subscribe/Unsubscribe | Update v v +------------------+ +-------------------+ | NewsPublisher | | NewsSubscriber | | (Subject) |-------| (Observer) | +------------------+ +-------------------+ Conclusion: The Observer Pattern is a powerful and flexible design pattern for building systems where objects need to be notified of changes to another object's state.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Gang of Four Patterns Design Patterns in C# · GoF Patterns

Short answer: The User class represents a user in the chat application.

Explain a bit more

Each user has a name and a reference to the mediator. When a user wants to send a message, they call Send() on the mediator, which then sends the message to all other registered users. Users only interact with the mediator, and not with each other directly. public class User public void Send(string message) => _mediator.SendMessage(message, this); public void Receive(string message) => Console.WriteLine($"{_name} received: {message}"); }

Example code

{
private readonly string _name;
private readonly IChatMediator _mediator;
public User(string name, IChatMediator mediator)
{
_name = name;
_mediator = mediator; _mediator.RegisterUser(this); // Register the user with the mediator }

Real-world example (ShopNest)

Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solves in the interview.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Gang of Four Patterns Design Patterns in C# · GoF Patterns

Short answer: The Iterator Pattern provides a consistent and uniform way to access elements of the collection, regardless of the underlying structure of the collection. Real-Time Use Case Examples:

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Gang of Four Patterns Design Patterns in C# · GoF Patterns

Short answer: The ProductIterator class is the concrete iterator that implements the IIterator<Product> interface. It holds a reference to the collection (ProductCollection) and provides the logic for iterating over it, including HasNext() and Next() methods to navigate through the collection. public class ProductIterator : IIterator<Product>

Example code

{
private readonly ProductCollection _collection;
private int _current = 0;
public ProductIterator(ProductCollection collection) =>
_collection = collection;
public bool HasNext() => _current < _collection.Count;
public Product Next() => _collection[_current++];
}

Real-world example (ShopNest)

Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solves in the interview.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Gang of Four Patterns Design Patterns in C# · GoF Patterns

Short answer: The Add class represents a non-terminal expression that combines two other expressions (leftExpression and rightExpression). The Interpret method evaluates both sides of the expression and returns their sum. public class Add : IExpression

Example code

{
private readonly IExpression _leftExpression;
private readonly IExpression _rightExpression;
public Add(IExpression left, IExpression right)
{
_leftExpression = left;
_rightExpression = right;
}
public int Interpret() => _leftExpression.Interpret() + _rightExpression.Interpret(); }

Real-world example (ShopNest)

Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solves in the interview.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Gang of Four Patterns Design Patterns in C# · GoF Patterns

Short answer: In the client code, we create a CharacterFactory instance to manage the characters. We then iterate over the text "Hello World", requesting a Character object for each character. The flyweight objects are reused, reducing memory consumption. class Program { static void Main() {

Example code

var factory = new CharacterFactory();
string text = "Hello World";
foreach (var c in text)
{
var character = factory.GetCharacter(c); character.Display(0, 0); // Simplified position for this example }
}
}

Real-world example (ShopNest)

Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solves in the interview.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Gang of Four Patterns Design Patterns in C# · GoF Patterns

Short answer: This is an abstract class that declares the CreateLogger method, which is intended to return an ILogger instance. The actual instantiation is delegated to subclasses. public abstract class LoggerFactory

Example code

{
public abstract ILogger CreateLogger();
}

Real-world example (ShopNest)

ShopNest’s NotificationFactory creates Email or SMS senders based on user preference.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Gang of Four Patterns Design Patterns in C# · GoF Patterns

Short answer: The CoffeeDecorator class is an abstract class that implements the ICoffee interface and holds a reference to an ICoffee object. This class allows us to add additional behavior to the coffee object, but we don't modify the base class (SimpleCoffee). public abstract class CoffeeDecorator : ICoffee

Example code

{ protected ICoffee _coffee; protected CoffeeDecorator(ICoffee coffee) => _coffee = coffee;
public virtual double Cost() => _coffee.Cost();
public virtual string Description() => _coffee.Description();
}

Real-world example (ShopNest)

Logging and caching decorators wrap IProductRepository so core SQL code stays clean.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Gang of Four Patterns Design Patterns in C# · GoF Patterns

Short answer: The Directory class represents the composite component in the tree structure. It can contain files or other directories. The Add() method is used to add components (both files and directories) to the directory. The ShowInfo() method iterates through its children and displays their information. public class Directory : IFileSystemComponent

Example code

{
private string _name;
private List<IFileSystemComponent> _children = new
List<IFileSystemComponent>();
public Directory(string name) => _name = name;
public void Add(IFileSystemComponent component) => _children.Add(component); public void ShowInfo()
{ Console.WriteLine($"Directory: {_name}"); foreach (var child in _children)
{ child.ShowInfo(); }
}
}

Real-world example (ShopNest)

Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solves in the interview.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Gang of Four Patterns Design Patterns in C# · GoF Patterns

Short answer: The Document class represents the receiver of the command. It contains the actual operations for adding and removing text from the document. The AddText and RemoveText methods manipulate the internal content (a StringBuilder).

Example code

public class Document
{
private readonly StringBuilder _content = new StringBuilder();
public void AddText(string text) => _content.Append(text);
public void RemoveText(string text) => _content.Remove(_content.Length - text.Length, text.Length); public override string ToString() => _content.ToString();
}

Real-world example (ShopNest)

Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solves in the interview.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Gang of Four Patterns Design Patterns in C# · GoF Patterns

Short answer: The LogLevel enum defines the different types of log messages (e.g., Info, Error). public enum LogLevel { Info, Error }

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Gang of Four Patterns Design Patterns in C# · GoF Patterns

Short answer: The MargheritaPizzaBuilder is a concrete implementation of the IPizzaBuilder interface. It builds a specific type of pizza (Margherita in this case) by setting the dough, sauce, and adding toppings. The Build() method returns the fully constructed pizza. public class MargheritaPizzaBuilder : IPizzaBuilder

Example code

{
private Pizza _pizza = new Pizza();
public void SetDough(string dough) => _pizza.Dough = dough;
public void SetSauce(string sauce) => _pizza.Sauce = sauce;
public void AddTopping(string topping) => _pizza.Toppings.Add(topping); public Pizza Build() => _pizza;
}

Real-world example (ShopNest)

Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solves in the interview.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Gang of Four Patterns Design Patterns in C# · GoF Patterns

Short answer: The DrawingAPI1 and DrawingAPI2 are concrete implementations of the IDrawingAPI interface. These classes implement the specific drawing logic for rendering circles, but they could use different libraries or methods (e.g., OpenGL, DirectX, Canvas API). public class DrawingAPI1 : IDrawingAPI

Example code

{
public void DrawCircle(double x, double y, double radius) => Console.WriteLine($"Drawing Circle at ({x}, {y}) with radius {radius} using API 1."); }
public class DrawingAPI2 : IDrawingAPI
{
public void DrawCircle(double x, double y, double radius) => Console.WriteLine($"Drawing Circle at ({x}, {y}) with radius {radius} using API 2."); }

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Gang of Four Patterns Design Patterns in C# · GoF Patterns

Short answer: The IButton and ICheckbox interfaces define the general contract for products. Each concrete product (e.g., WindowsButton, MacButton) will implement the Render method to display platform-specific UI elements. public interface IButton { void Render(); }

Example code

public interface ICheckbox { void Render(); }

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Gang of Four Patterns Design Patterns in C# · GoF Patterns

Short answer: other expressions. It leverages the recursive nature of the Interpreter Pattern to evaluate complex expressions.

Real-world example (ShopNest)

Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solves in the interview.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Gang of Four Patterns Design Patterns in C# · GoF Patterns

Short answer: How It Works:? is a common interview topic in Gang of Four Patterns. Give a clear definition, then one concrete example.

Real-world example (ShopNest)

Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solves in the interview.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Gang of Four Patterns Design Patterns in C# · GoF Patterns

Short answer: And undoing commands. When a command is executed, it’s pushed onto the stack. The Undo() method pops the last executed command and undoes its ction. public class TextEditor { private readonly Stack<ICommand> _commandHistory = new Stack<ICommand>(); public void ExecuteCommand(ICommand command) { command.Execute(); _commandHistory.Push(command); } public… void… nd undoing commands. When a command is executed, it’s…

Explain a bit more

pushed onto the stack. The Undo() method pops the last executed command and undoes its ction. public class TextEditor { private readonly Stack<ICommand> _commandHistory = new Stack<ICommand>(); public void ExecuteCommand(ICommand command) { command.Execute(); _commandHistory.Push(command); } public void Undo() { if (_commandHistory.Count > 0) { var command = _commandHistory.Pop(); command.Undo(); } } } And undoing commands. When a command is executed, it’s pushed onto the stack. The Undo() method pops the last executed command and undoes its ction. public class TextEditor { private readonly Stack<ICommand> _commandHistory = new… { command.Execute(); _commandHistory.Push(command); }

Example code

public void Undo()
{
if (_commandHistory.Count > 0)
{
var command = _commandHistory.Pop(); command.Undo(); }
}
}

Real-world example (ShopNest)

Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solves in the interview.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Gang of Four Patterns Design Patterns in C# · GoF Patterns

Short answer: ppropriate methods on the builder. It then returns the final product. public class PizzaDirector { private readonly IPizzaBuilder _builder; public PizzaDirector(IPizzaBuilder builder) => _builder = builder; public Pizza ConstructMargheritaPizza() { _builder.SetDough("Thin Crust"); _builder.SetSauce("Tomato"); _builder.AddTopping("Mozzarella"); return…… ppropriate methods on the builder. It then returns the final…

Explain a bit more

product. public class PizzaDirector { private readonly IPizzaBuilder _builder; public PizzaDirector(IPizzaBuilder builder) => _builder = builder; public Pizza ConstructMargheritaPizza() { _builder.SetDough("Thin Crust"); _builder.SetSauce("Tomato"); _builder.AddTopping("Mozzarella"); return _builder.Build(); } } ppropriate methods on the builder. It then returns the final product. public class PizzaDirector { private readonly IPizzaBuilder _builder; public PizzaDirector(IPizzaBuilder builder) => _builder = builder; public Pizza ConstructMargheritaPizza()

Example code

{ _builder.SetDough("Thin Crust"); _builder.SetSauce("Tomato"); _builder.AddTopping("Mozzarella"); return _builder.Build();
}
}

Real-world example (ShopNest)

Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solves in the interview.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Gang of Four Patterns Design Patterns in C# · GoF Patterns

Short answer: daptee adaptee = new Adaptee(); ITarget adapter = new Adapter(adaptee); dapter.Request(); // Outputs: Specific request from daptee.

Explain a bit more

} } daptee adaptee = new Adaptee(); ITarget adapter = new Adapter(adaptee); dapter.Request(); // Outputs: Specific request from daptee. } } daptee adaptee = new Adaptee(); ITarget adapter = new Adapter(adaptee); dapter.Request(); // Outputs: Specific request from daptee. } } daptee adaptee = new Adaptee(); ITarget adapter = new Adapter(adaptee); dapter.Request(); // Outputs: Specific request from daptee. } }

Real-world example (ShopNest)

Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solves in the interview.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Gang of Four Patterns Design Patterns in C# · GoF Patterns

Short answer: The Product class represents an individual product with a property Name. This is the item that we will iterate over in the collection. public class Product

Example code

{
public string Name { get; }
public Product(string name) => Name = name;
}

Real-world example (ShopNest)

Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solves in the interview.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Gang of Four Patterns Design Patterns in C# · GoF Patterns

Short answer: In the Main method, we create two Number expressions (5 and 10) and then create an Add expression to combine them. Finally, we evaluate the expression by calling Interpret on the addExpression object. class Program { static void Main() {

Example code

IExpression number1 = new Number(5);
IExpression number2 = new Number(10);
IExpression addExpression = new Add(number1, number2); Console.WriteLine($"Result: {addExpression.Interpret()}"); // Outputs: Result: 15 }
}

Real-world example (ShopNest)

Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solves in the interview.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Gang of Four Patterns Design Patterns in C# · GoF Patterns

Short answer: These subclasses of LoggerFactory override the CreateLogger method to return the appropriate logger type (either FileLogger or ConsoleLogger). FileLoggerFactory: public class FileLoggerFactory : LoggerFactory

Example code

{
public override ILogger CreateLogger() => new FileLogger();
} ConsoleLoggerFactory: public class ConsoleLoggerFactory : LoggerFactory
{
public override ILogger CreateLogger() => new ConsoleLogger();
}

Real-world example (ShopNest)

ShopNest’s NotificationFactory creates Email or SMS senders based on user preference.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details