Master technical and career interviews with structured answers—short definition, real examples, pitfalls, and how to answer in 60–90 seconds.
Answer: The Directory class currently only has an Add() method for adding components. It could be improved by adding a Remove() method to allow for the dynamic removal of files or subdirectories. What interviewers expect…
The most common application of the Composite Pattern is in representing file systems. A file system is inherently hierarchical: directories contain files and subdirectories, and those subdirectories can contain further f…
Answer: Both files and directories are treated the same, as they implement the IFileSystemComponent interface. This makes it easier to manage a mixed structure of individual and composite objects. What interviewers expec…
Answer: Both File and Directory implement the IFileSystemComponent interface, which defines the common method ShowInfo(). This allows us to treat both files and directories uniformly. What interviewers expect A clear def…
Answer: This is the base interface that defines a common method ShowInfo() that will be implemented by both leaf and composite components. public interface IFileSystemComponent { void ShowInfo(); } What interviewers expe…
Answer: You can extend the system by adding redo functionality. After an undo operation, you could store the undone command in a separate stack and allow users to redo the previous undo operation. What interviewers expec…
Answer: The sender (the TextEditor) is decoupled from the receiver (Document). The TextEditor only knows how to invoke commands but does not need to understand the details of the operations (e.g., how the text is added o…
The command (in this case, AddTextCommand) encapsulates the request to add text to the document as an object. This allows for parameterization of the command with different requests (e.g., adding different text) while de…
Answer: The ICommand interface defines two methods: ■ Execute(): Executes the command. ■ Undo(): Reverts the command if the user wishes to undo the action. public interface ICommand { void Execute(); void Undo(); } What…
Answer: The Chain of Responsibility allows handlers to be decoupled from the client code. The client doesn’t need to know which handler will process the request, only that the request will eventually be processed by some…
In the Program class, we set up a chain of responsibility by calling SetNext() on the infoLogger and passing it the errorLogger. This ensures that the InfoLogger will process log messages with the Info level, while the E…
The Logger class is the handler interface that defines the contract for handling log messages. It includes a reference to the next logger in the chain (NextLogger) and a method (LogMessage) to process a message. If the c…
Answer: The Builder Pattern separates the construction of a complex object from its representation. You can change the construction process without changing the way the object is represented or structured. What interview…
The Pizza class is the Product that we are constructing. It has properties for Dough, Sauce, and a list of Toppings. The ToString() method is overridden to provide a string representation of the pizza. public class Pizza…
Answer: The Bridge pattern allows you to modify the abstraction (shapes) and the implementation (drawing API) independently, providing a cleaner and more modular design. What interviewers expect A clear definition tied t…
The Shape class is the abstraction. It holds a reference to the IDrawingAPI and delegates the drawing task to it. It defines the common interface Draw() that all shapes must implement. public abstract class Shape { prote…
Answer: The Adapter pattern allows you to integrate existing systems or third-party libraries without modifying their code. It enables compatibility between incompatible interfaces. What interviewers expect A clear defin…
Answer: The ITarget interface defines the expected interface that the client will use. It has a method Request() that the client expects to call. public interface ITarget { void Request(); } What interviewers expect A cl…
The IUIFactory interface defines methods for creating abstract product types like buttons and checkboxes. This ensures that every concrete factory will implement the same methods, but each will provide platform-specific…
Answer: the existing classes. This pattern allows you to keep your object classes stable and add functionality through new visitor classes. What interviewers expect A clear definition tied to GoF Patterns in Gang of Four…
chieved by selecting different algorithms. What interviewers expect A clear definition tied to GoF Patterns in Gang of Four Patterns projects Trade-offs (performance, maintainability, security, cost) When you would and w…
Answer: lgorithm. These algorithms can be tested, optimized, or replaced without ffecting the context or the other algorithms. What interviewers expect A clear definition tied to GoF Patterns in Gang of Four Patterns pro…
Answer: pplication log to the same destination (e.g., a log file or a central logging service). What interviewers expect A clear definition tied to GoF Patterns in Gang of Four Patterns projects Trade-offs (performance,…
ctual state (the text) and provides methods to change the state, save the current state to a Memento, and restore a previous state from a Memento. The Save() method creates a new TextMemento capturing the current state o…
Answer: dding new features like message filtering or logging can be done in the mediator without affecting the users. What interviewers expect A clear definition tied to GoF Patterns in Gang of Four Patterns projects Tra…
Gang of Four Patterns Design Patterns in C# · GoF Patterns
Answer: The Directory class currently only has an Add() method for adding components. It could be improved by adding a Remove() method to allow for the dynamic removal of files or subdirectories.
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
file systems. A file system is inherently hierarchical: directories contain files
and subdirectories, and those subdirectories can contain further files or
subdirectories. The Composite Pattern allows for easy traversal and
management of this hierarchical structure.
Gang of Four Patterns Design Patterns in C# · GoF Patterns
Answer: Both files and directories are treated the same, as they implement the IFileSystemComponent interface. This makes it easier to manage a mixed structure of individual and composite objects.
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: Both File and Directory implement the IFileSystemComponent interface, which defines the common method ShowInfo(). This allows us to treat both files and directories uniformly.
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: This is the base interface that defines a common method ShowInfo() that will be implemented by both leaf and composite components. public interface IFileSystemComponent { void ShowInfo(); }
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: You can extend the system by adding redo functionality. After an undo operation, you could store the undone command in a separate stack and allow users to redo the previous undo operation.
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: The sender (the TextEditor) is decoupled from the receiver (Document). The TextEditor only knows how to invoke commands but does not need to understand the details of the operations (e.g., how the text is added or removed).
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
add text to the document as an object. This allows for parameterization of the
command with different requests (e.g., adding different text) while decoupling
the sender (the TextEditor) from the receiver (Document).
Follow:
Gang of Four Patterns Design Patterns in C# · GoF Patterns
Answer: The ICommand interface defines two methods: ■ Execute(): Executes the command. ■ Undo(): Reverts the command if the user wishes to undo the action. public interface ICommand { void Execute(); void Undo(); }
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: The Chain of Responsibility allows handlers to be decoupled from the client code. The client doesn’t need to know which handler will process the request, only that the request will eventually be processed by some handler in the chain.
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
SetNext() on the infoLogger and passing it the errorLogger. This
ensures that the InfoLogger will process log messages with the Info level,
while the ErrorLogger will handle Error level messages.
Gang of Four Patterns Design Patterns in C# · GoF Patterns
handling log messages. It includes a reference to the next logger in the chain
(NextLogger) and a method (LogMessage) to process a message. If the
current handler cannot handle the message, it passes the request along to
the next handler in the chain.
public abstract class Logger
{
protected Logger NextLogger;
public void SetNext(Logger nextLogger) => NextLogger =
nextLogger;
public void LogMessage(string message, LogLevel level)
{
if (CanHandle(level))
{
Handle(message);
}
else
{
NextLogger?.LogMessage(message, level);
}
}
protected abstract bool CanHandle(LogLevel level);
protected abstract void Handle(string message);
}Gang of Four Patterns Design Patterns in C# · GoF Patterns
Answer: The Builder Pattern separates the construction of a complex object from its representation. You can change the construction process without changing the way the object is represented or structured.
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
Dough, Sauce, and a list of Toppings. The ToString() method is
overridden to provide a string representation of the pizza.
public class Pizza
{
public string Dough { get; set; }
public string Sauce { get; set; }
public List<string> Toppings { get; } = new List<string>();
public override string ToString() =>
$"Pizza with {Dough} dough, {Sauce} sauce and toppings:
{string.Join(", ", Toppings)}";
}Gang of Four Patterns Design Patterns in C# · GoF Patterns
Answer: The Bridge pattern allows you to modify the abstraction (shapes) and the implementation (drawing API) independently, providing a cleaner and more modular design.
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
IDrawingAPI and delegates the drawing task to it. It defines the common
interface Draw() that all shapes must implement.
public abstract class Shape
{
protected IDrawingAPI _drawingAPI;
protected Shape(IDrawingAPI drawingAPI) => _drawingAPI =
drawingAPI;
public abstract void Draw();
}Gang of Four Patterns Design Patterns in C# · GoF Patterns
Answer: The Adapter pattern allows you to integrate existing systems or third-party libraries without modifying their code. It enables compatibility between incompatible interfaces.
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: The ITarget interface defines the expected interface that the client will use. It has a method Request() that the client expects to call. public interface ITarget { void Request(); }
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
types like buttons and checkboxes. This ensures that every concrete factory
will implement the same methods, but each will provide platform-specific
products.
public interface IUIFactory
{
IButton CreateButton();
ICheckbox CreateCheckbox();
}Gang of Four Patterns Design Patterns in C# · GoF Patterns
Answer: the existing classes. This pattern allows you to keep your object classes stable and add functionality through new visitor classes.
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
chieved by selecting different algorithms.
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: lgorithm. These algorithms can be tested, optimized, or replaced without ffecting the context or the other algorithms.
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: pplication log to the same destination (e.g., a log file or a central logging service).
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
ctual state (the text) and provides methods to change the state, save the current
state to a Memento, and restore a previous state from a Memento.
editor.
public class TextEditor
{
private string _text;
public void Write(string text) => _text = text;
public TextMemento Save() => new TextMemento(_text);
public void Restore(TextMemento memento) => _text =
memento.Text;
public override string ToString() => _text;
}Gang of Four Patterns Design Patterns in C# · GoF Patterns
Answer: dding new features like message filtering or logging can be done in the mediator without affecting the users.
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.