Concrete Aggregate (ProductCollection):?
Short answer: The ProductCollection class is a concrete aggregate that implements the IAggregate<Product> interface. It maintains a list of Product objects and provides an Add() method to add products. It also implements CreateIterator() to return an instance of ProductIterator, enabling iteration over the collection. public class ProductCollection : IAggregate<Product>
Example code
{
private readonly List<Product> _products = new List<Product>();
public void Add(Product product) => _products.Add(product);
public int Count => _products.Count;
public Product this[int index] => _products[index];
public IIterator<Product> CreateIterator() => new ProductIterator(this); }
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
- Define — one clear sentence (the short answer above).
- Example — relate it to a project like ShopNest or your real work.
- Trade-off — when you would not use it.
Share this Q&A
Share preview image: https://www.toolliyo.com/images/toolliyo-logo.png