mnichols, could you explain why having business logic in an
OnAdding operation is more difficult to debug then an
Add operation?
What do you mean by event driven mechanisms within the same layer? The NotifyingList is not a domain object but a collection type just like List except it exposes events for operations that manipulate the collection.
To me, I think my domain model is cleaner and more intention revealing to have this:
Code:
parent.Children.Add(newChild);
Child existingChile = parent.Childern[0];
parent.Children.Remove(existingChild);
as opposed to this:
Code:
parent.AddChild(newChild);
Child existingChild = parent.Children[0];
parent.RemoveChild(existingChild);
With the first code block, I can work directly with the collection, the second code block has to route all collection manipulation through the parent. and I have to do tricks like returning read only collection from parent.Children.
Maybe its a matter of taste, but I like the first way better. I havent ran into any debug problems but Im interested to know why having an observer in the domain model would be frowned upon? Thanks for any clarification on this.