Mid From PDF GoF Patterns Gang of Four Patterns

Concrete Visitor Class (ShoppingCart):?

Short answer: The concrete visitor ShoppingCart implements the IShoppingCartVisitor interface. It performs specific operations on each element, like calculating the total cost with any applicable discounts. For instance, it applies a 10% discount to books but no discount to fruits. public class ShoppingCart : IShoppingCartVisitor

Example code

{
private double _total;
public void Visit(Book book) => _total += book.Price * 0.9; // 10% discount on books public void Visit(Fruit fruit) => _total += fruit.Price; // No discount on fruits public double GetTotal() => _total;
}

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.
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