I am trying to understand DDD. Infact it looks I have some missing points on OOP. Let's think that we have a domain model called Product. Based on OOP, data and behaviour must be hold together. Example maybe wrong but data and behavior are together below.
public class Product
{
public Guid Id { get; set; }
public double TaxRate { get; set; }
public double Price { get; set; }
public double GetFinalPrice()
{
return Price * TaxRate;
}
}
Let's think that we need to fetch all products in a category, in this case should I add a method in Product class to return all products in a category? It doesn't look good to me, because a GetProducts behaviour cannot be in Product object.
In this case should I create a CategoryProductFetcher object and add a method Fetch for behaviour?It also sounds wrong because I will have a class for all list methods.
Could you help me about the concept or any documents that explain this? I read lots of article but all are to basic and not explaining more.
Thanks in advance