Where does the logic for deleting/not deleting dependent objects belong in DDD?
For instance one has a category that contains products:
class Category
{
IList<Products> products;
}
A rule might be that a category cannot be deleted unless it has no products.
Where does the logic belong that does the check for no products under this category before deleting it?
- Domain classes - It appears to be business logic so I would surmise that it belong in the domain layer.
- Repository classes - The repository layer handles persistence, it has the general CRUD methods, including one for deleting, does the logic belong in this layer?
- Another solution?