Master technical and career interviews with structured answers—short definition, real examples, pitfalls, and how to answer in 60–90 seconds.
Short 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 Example code { void ShowInfo(); } Rea…
Short 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. Real-world exampl…
Short 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 a…
Short answer: 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…
Short 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 Example code { void Execute(); v…
Short 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 b…
Short answer: 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 leve…
Short answer: 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 mes…
Short 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. Real-wor…
Short answer: 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. publ…
Short answer: The Bridge pattern allows you to modify the abstraction (shapes) and the implementation (drawing API) independently, providing a cleaner and more modular design. Real-world example (ShopNest) Use a GoF patt…
Short answer: 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. Example code public a…
Short answer: The Adapter pattern allows you to integrate existing systems or third-party libraries without modifying their code. It enables compatibility between incompatible interfaces. Real-world example (ShopNest) Us…
Short 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 Example code { void Request(); } Real-world…
Short answer: The pattern separates the UI creation logic from the client application. The application does not need to know about the specific UI components; it simply relies on the factory to provide them. Real-world e…
Short answer: 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 plat…
Short answer: the existing classes. This pattern allows you to keep your object classes stable and add functionality through new visitor classes. Real-world example (ShopNest) Use a GoF pattern in ShopNest only when it r…
Short answer: lgorithm. These algorithms can be tested, optimized, or replaced without ffecting the context or the other algorithms. Real-world example (ShopNest) Discount rules are Strategy objects: PercentageOff, FlatO…
Short answer: dding new features like message filtering or logging can be done in the mediator without affecting the users. Real-world example (ShopNest) Use a GoF pattern in ShopNest only when it removes duplication or…
Short answer: ccess the elements sequentially, leading to cleaner and more maintainable code. Real-world example (ShopNest) Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain t…
Short answer: n iterator for that collection. 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…
Short answer: ccess to the shared flyweight objects. Real-world example (ShopNest) ShopNest’s NotificationFactory creates Email or SMS senders based on user preference. Say this in the interview Define — one clear senten…
Short answer: synchronous, allowing components (like the DVD player) to load or process content in the background, improving user experience. Real-world example (ShopNest) Use a GoF pattern in ShopNest only when it remov…
Short answer: mplifier or DVDPlayer, reducing tight coupling between them. Real-world example (ShopNest) Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solve…
Short answer: n individual object, while a group of shapes can be treated as a composite object. The Composite Pattern makes it easier to manage complex graphical objects that contain simple shapes. Real-world example (S…
Gang of Four Patterns Design Patterns in C# · GoF Patterns
Short 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(); }
Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solves in the interview.
Gang of Four Patterns Design Patterns in C# · GoF Patterns
Short 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.
Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solves in the interview.
Gang of Four Patterns Design Patterns in C# · GoF Patterns
Short 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).
Gang of Four Patterns Design Patterns in C# · GoF Patterns
Short answer: 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 decoupling the sender (the TextEditor) from the receiver (Document).
Gang of Four Patterns Design Patterns in C# · GoF Patterns
Short 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(); }
Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solves in the interview.
Gang of Four Patterns Design Patterns in C# · GoF Patterns
Short 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.
Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solves in the interview.
Gang of Four Patterns Design Patterns in C# · GoF Patterns
Short answer: 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 ErrorLogger will handle Error level messages.
Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solves in the interview.
Gang of Four Patterns Design Patterns in C# · GoF Patterns
Short answer: 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 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); }
Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solves in the interview.
Gang of Four Patterns Design Patterns in C# · GoF Patterns
Short 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.
Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solves in the interview.
Gang of Four Patterns Design Patterns in C# · GoF Patterns
Short answer: 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
{
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)}"; }
Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solves in the interview.
Gang of Four Patterns Design Patterns in C# · GoF Patterns
Short answer: The Bridge pattern allows you to modify the abstraction (shapes) and the implementation (drawing API) independently, providing a cleaner and more modular design.
Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solves in the interview.
Gang of Four Patterns Design Patterns in C# · GoF Patterns
Short answer: 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
{ protected IDrawingAPI _drawingAPI; protected Shape(IDrawingAPI drawingAPI) => _drawingAPI = drawingAPI; public abstract void Draw();
}
Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solves in the interview.
Gang of Four Patterns Design Patterns in C# · GoF Patterns
Short answer: The Adapter pattern allows you to integrate existing systems or third-party libraries without modifying their code. It enables compatibility between incompatible interfaces.
Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solves in the interview.
Gang of Four Patterns Design Patterns in C# · GoF Patterns
Short 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(); }
Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solves in the interview.
Gang of Four Patterns Design Patterns in C# · GoF Patterns
Short answer: The pattern separates the UI creation logic from the client application. The application does not need to know about the specific UI components; it simply relies on the factory to provide them.
Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solves in the interview.
Gang of Four Patterns Design Patterns in C# · GoF Patterns
Short answer: 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 products. public interface IUIFactory
{ IButton CreateButton(); ICheckbox CreateCheckbox(); }
ShopNest’s NotificationFactory creates Email or SMS senders based on user preference.
Gang of Four Patterns Design Patterns in C# · GoF Patterns
Short answer: the existing classes. This pattern allows you to keep your object classes stable and add functionality through new visitor classes.
Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solves in the interview.
Gang of Four Patterns Design Patterns in C# · GoF Patterns
Short answer: lgorithm. These algorithms can be tested, optimized, or replaced without ffecting the context or the other algorithms.
Discount rules are Strategy objects: PercentageOff, FlatOff, BuyOneGetOne—checkout picks one without a huge if/else.
Gang of Four Patterns Design Patterns in C# · GoF Patterns
Short answer: dding new features like message filtering or logging can be done in the mediator without affecting the users.
Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solves in the interview.
Gang of Four Patterns Design Patterns in C# · GoF Patterns
Short answer: ccess the elements sequentially, leading to cleaner and more maintainable code.
Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solves in the interview.
Gang of Four Patterns Design Patterns in C# · GoF Patterns
Short answer: n iterator for that collection.
Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solves in the interview.
Gang of Four Patterns Design Patterns in C# · GoF Patterns
Short answer: ccess to the shared flyweight objects.
ShopNest’s NotificationFactory creates Email or SMS senders based on user preference.
Gang of Four Patterns Design Patterns in C# · GoF Patterns
Short answer: synchronous, allowing components (like the DVD player) to load or process content in the background, improving user experience.
Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solves in the interview.
Gang of Four Patterns Design Patterns in C# · GoF Patterns
Short answer: mplifier or DVDPlayer, reducing tight coupling between them.
Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solves in the interview.
Gang of Four Patterns Design Patterns in C# · GoF Patterns
Short answer: n individual object, while a group of shapes can be treated as a composite object. The Composite Pattern makes it easier to manage complex graphical objects that contain simple shapes.
Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solves in the interview.
Install Toolliyo like an app Free
Home-screen access to tutorials, coding practice & career tools — no app store needed.
On iPhone/iPad: tap Share then Add to Home Screen.