Archive for the ‘DDD’ Category

DDD infected

July 11th, 2007

Just caught myself writing this snippet just now:

public class SessionCart
{
	private List<CartLine> lines = new List<CartLine>();

	public CartLine AddLine(ProductVariation productVariation)
	{
		CartLine line = GetLineByProductVariation(productVariation);
	
		if (line != null)
		{
			line.IncrementQuantity();
		}
		else 
		{
			line = new CartLine(...);
		
			lines.Add(line);
		}

		return line;
	}

	...

Where IncrementQuantity is

public void IncrementQuantity()
{
    quantity++;
}

…and said to myself “Ok, I’m Domain-Driven Design infected”