Master technical and career interviews with structured answers—short definition, real examples, pitfalls, and how to answer in 60–90 seconds.
The Singleton pattern ensures a class has only one instance and provides a global point of ccess to it. It’s commonly used when exactly one object is needed to coordinate actions cross the system, such as configuration s…
parameter to facilitate the state change. public interface ITrafficLightState { void Change(TrafficLight light); } Each concrete state class (Red, Green, Yellow) will implement this interface, defining the specific behav…
Answer: n update. public interface INewsPublisher { void Subscribe(IObserver observer); void Unsubscribe(IObserver observer); void Notify(string news); } What interviewers expect A clear definition tied to GoF Patterns i…
Answer: ll types of loggers (e.g., file, console). public interface ILogger { void Log(string message); } What interviewers expect A clear definition tied to GoF Patterns in Gang of Four Patterns projects Trade-offs (per…
Answer: nd Description() that every coffee component will implement. public interface ICoffee { double Cost(); string Description(); } What interviewers expect A clear definition tied to GoF Patterns in Gang of Four Patt…
Answer: Subclasses, like PastaRecipe, implement the GatherIngredients, Prepare, and CookMethod methods. These methods contain the specific details of the recipe, such as the ingredients, preparation steps, and cooking pr…
Answer: s a Build() method to return the fully constructed pizza. public interface IPizzaBuilder { void SetDough(string dough); void SetSauce(string sauce); void AddTopping(string topping); Pizza Build(); } What intervie…
The Factory pattern is a creational design pattern that provides an interface for creating objects but allows subclasses or implementations to decide which class to instantiate. It’s used to encapsulate object creation,…
The Strategy pattern is a behavioral design pattern that defines a family of algorithms, encapsulates each one, and makes them interchangeable at runtime. It allows the algorithm to vary independently from clients that u…
pplications? The Repository pattern abstracts the data access layer from the business logic by providing collection-like interface to access domain objects. It helps keep data access logic centralized and makes the codeb…
The Repository pattern abstracts the data access layer from the business logic by providing a collection-like interface to access domain objects. It helps keep data access logic centralized and makes the codebase easier…
The Unit of Work pattern is a design pattern used to maintain a list of operations to be performed within a single transaction. It ensures that all operations either succeed or fail together, providing consistency and ma…
Dependency Injection (DI) is a design pattern that allows an object to receive its dependencies from an external source rather than creating them itself. This promotes loose coupling, enhances testability, and simplifies…
Transient: A new instance is created every time it is requested. Scoped: A single instance is created per request/HTTP request. Singleton: A single instance is created and shared across the application lifetime. Lifetime…
The Single Responsibility Principle (SRP) states that a class should have only one reason to change. In other words, it should have only one responsibility or job. Each class should do one thing, and do it well. For exam…
Before (OCP Violation): public class DiscountCalculator { public decimal CalculateDiscount(string customerType) { if (customerType == "Regular") return 10; if (customerType == "Premium") return 20; if (customerType == "V…
The Liskov Substitution Principle (LSP) states that: Subtypes must be substitutable for their base types without altering the correctness of the program. In other words, if class S is a subclass of class T, then objects…
Example (Violation of LSP): public class Rectangle { public virtual int Width { get; set; } public virtual int Height { get; set; } public int Area() => Width * Height; } public class Square : Rectangle { public overr…
Answer: No client should be forced to implement methods it does not use. Break large interfaces into smaller, focused interfaces. What interviewers expect A clear definition tied to SOLID in Design Patterns & SOLID p…
The Dependency Inversion Principle (DIP) states that: High-level modules should not depend on low-level modules. Both should depend on abstractions. bstractions should not depend on details. Details should depend on bstr…
DAO (Data Access Object) focuses on low-level database operations and CRUD, typically mapping tables to objects. Repository abstracts data access at the domain level, working with aggregates/entities and encapsulating bu…
IServiceCollection: A container used during app startup to register services and their lifetimes (Scoped, Transient, Singleton). It acts as a service registry. IServiceProvider: The built container that resolves and prov…
Inheritance creates an “is-a” relationship, where a subclass inherits behavior and properties from a parent class. It can lead to tight coupling and fragile hierarchies if overused. Composition creates a “has-a” relation…
Cohesion: Degree to which elements of a module belong together. High cohesion means focused, well-defined responsibilities. Coupling: Degree of interdependence between modules. Low coupling means modules are independent…
Design Patterns & SOLID Design Patterns in C# · SOLID
The Singleton pattern ensures a class has only one instance and provides a global point of
ccess to it. It’s commonly used when exactly one object is needed to coordinate actions
cross the system, such as configuration settings, logging, or caching.
Gang of Four Patterns Design Patterns in C# · GoF Patterns
parameter to facilitate the state change.
public interface ITrafficLightState
{
void Change(TrafficLight light);
}
the specific behavior of the traffic light for that state.
Gang of Four Patterns Design Patterns in C# · GoF Patterns
Answer: n update. public interface INewsPublisher { void Subscribe(IObserver observer); void Unsubscribe(IObserver observer); void Notify(string news); }
In a production Gang of Four Patterns application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Gang of Four Patterns Design Patterns in C# · GoF Patterns
Answer: ll types of loggers (e.g., file, console). public interface ILogger { void Log(string message); }
In a production Gang of Four Patterns application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Gang of Four Patterns Design Patterns in C# · GoF Patterns
Answer: nd Description() that every coffee component will implement. public interface ICoffee { double Cost(); string Description(); }
In a production Gang of Four Patterns application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Gang of Four Patterns Design Patterns in C# · GoF Patterns
Answer: Subclasses, like PastaRecipe, implement the GatherIngredients, Prepare, and CookMethod methods. These methods contain the specific details of the recipe, such as the ingredients, preparation steps, and cooking process.
In a production Gang of Four Patterns application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Gang of Four Patterns Design Patterns in C# · GoF Patterns
Answer: s a Build() method to return the fully constructed pizza. public interface IPizzaBuilder { void SetDough(string dough); void SetSauce(string sauce); void AddTopping(string topping); Pizza Build(); }
In a production Gang of Four Patterns application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Design Patterns & SOLID Design Patterns in C# · SOLID
The Factory pattern is a creational design pattern that provides an interface for creating
objects but allows subclasses or implementations to decide which class to instantiate. It’s
used to encapsulate object creation, promoting loose coupling and flexibility when the exact
types of objects aren’t known until runtime.
Use case: When a class can’t anticipate the class of objects it needs to create, or when you
want to delegate responsibility for object creation to subclasses.
Design Patterns & SOLID Design Patterns in C# · SOLID
The Strategy pattern is a behavioral design pattern that defines a family of algorithms,
encapsulates each one, and makes them interchangeable at runtime.
It allows the algorithm to vary independently from clients that use it.
Problem it solves:
voids large if-else or switch statements when selecting behavior and promotes
flexibility by decoupling the algorithm from the client using it.
Design Patterns & SOLID Design Patterns in C# · SOLID
pplications?
The Repository pattern abstracts the data access layer from the business logic by providing
collection-like interface to access domain objects.
It helps keep data access logic centralized and makes the codebase easier to maintain,
test, and swap out data sources (e.g., switching from EF Core to Dapper or an API).
Design Patterns & SOLID Design Patterns in C# · SOLID
The Repository pattern abstracts the data access layer from the business logic by providing
a collection-like interface to access domain objects.
It helps keep data access logic centralized and makes the codebase easier to maintain,
test, and swap out data sources (e.g., switching from EF Core to Dapper or an API).
Design Patterns & SOLID Design Patterns in C# · SOLID
The Unit of Work pattern is a design pattern used to maintain a list of operations to be
performed within a single transaction. It ensures that all operations either succeed or fail
together, providing consistency and managing changes to multiple business objects during a
transaction. It coordinates the writing out of changes and resolves potential concurrency
issues.
Design Patterns & SOLID Design Patterns in C# · SOLID
Dependency Injection (DI) is a design pattern that allows an object to receive its
dependencies from an external source rather than creating them itself. This promotes loose
coupling, enhances testability, and simplifies code maintenance.
Benefits:
Principle)
Design Patterns & SOLID Design Patterns in C# · SOLID
Lifetime Created Per Use Case
Transient Every injection Lightweight, stateless services
Scoped HTTP Request Web services handling per-request
data
Singleton App lifetime Logging, configuration, cache
Design Patterns & SOLID Design Patterns in C# · SOLID
The Single Responsibility Principle (SRP) states that a class should have only one
reason to change. In other words, it should have only one responsibility or job.
Each class should do one thing, and do it well.
For example, a class that handles user authentication should not also be responsible for
logging or sending emails.
Design Patterns & SOLID Design Patterns in C# · SOLID
Before (OCP Violation):
public class DiscountCalculator
{
public decimal CalculateDiscount(string customerType)
{
if (customerType == "Regular") return 10;
if (customerType == "Premium") return 20;
if (customerType == "VIP") return 30;
return 0;
}
}
If you need to support a new customer type, you must modify this method — violating OCP.
fter (OCP Compliant):
public interface IDiscountStrategy
{
decimal GetDiscount();
}
public class RegularCustomerDiscount : IDiscountStrategy
{
public decimal GetDiscount() => 10;
}
public class PremiumCustomerDiscount : IDiscountStrategy
{
public decimal GetDiscount() => 20;
}
public class VipCustomerDiscount : IDiscountStrategy
{
public decimal GetDiscount() => 30;
}
Now you can add new customer types without modifying existing code — just create a new
strategy.
Design Patterns & SOLID Design Patterns in C# · SOLID
The Liskov Substitution Principle (LSP) states that:
Subtypes must be substitutable for their base types without altering the
correctness of the program.
In other words, if class S is a subclass of class T, then objects of type T should be
replaceable with objects of type S without breaking the application.
This ensures that inheritance models is-a relationships correctly.
Design Patterns & SOLID Design Patterns in C# · SOLID
Example (Violation of LSP):
public class Rectangle
{
public virtual int Width { get; set; }
public virtual int Height { get; set; }
public int Area() => Width * Height;
}
public class Square : Rectangle
{
public override int Width
{
set { base.Width = base.Height = value; }
}
public override int Height
{
set { base.Width = base.Height = value; }
}
}
Now if you substitute Rectangle with Square:
Rectangle rect = new Square();
rect.Width = 5;
rect.Height = 10;
Console.WriteLine(rect.Area()); // Outputs 100, but logically
expected 50
❌ The behavior is incorrect — this is a violation of LSP.
Design Patterns & SOLID Design Patterns in C# · SOLID
Answer: No client should be forced to implement methods it does not use. Break large interfaces into smaller, focused interfaces.
In a production Design Patterns & SOLID application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Design Patterns & SOLID Design Patterns in C# · SOLID
The Dependency Inversion Principle (DIP) states that:
High-level modules should not depend on low-level modules. Both should
depend on abstractions.
bstractions should not depend on details. Details should depend on
bstractions.
In other words:
bstract classes.
Design Patterns & SOLID Design Patterns in C# · SOLID
DAO (Data Access Object) focuses on low-level database operations and CRUD, typically
mapping tables to objects.
Repository abstracts data access at the domain level, working with aggregates/entities and
encapsulating business logic. Repository often uses DAO internally but is more aligned with
domain-driven design.
Design Patterns & SOLID Design Patterns in C# · SOLID
their lifetimes (Scoped, Transient, Singleton). It acts as a service registry.
registered services at runtime. It uses the registrations to create and inject
dependencies.
Design Patterns & SOLID Design Patterns in C# · SOLID
properties from a parent class. It can lead to tight coupling and fragile hierarchies if
overused.
other classes and delegates behavior to them. It’s more flexible and promotes loose
coupling.
Design Patterns & SOLID Design Patterns in C# · SOLID
means focused, well-defined responsibilities.
modules are independent and changes in one don’t affect others.