0
我已經在我的書籍和互聯網上搜索了我的問題的答案,但我沒有找到答案。也許你可以幫助我。這是正確的域模型嗎?
讓我們假設我已經域層以這種方式counstructed(我認爲這是basical stucture):
Product
IProductRepository
IProductService
ProductCalculator
class ProductService : IProductService
//..
public List<Product> GetSimilarProducts(productId) {
// body of this method is just an example, it doesn't have sense
var product = repo.FindById(productId)
repo.FindBySimilarName(product.Name);
// some more logic
// and more
return similarsProducts;
}
//..
class ProductCalculator : ICalculate
//..
private Product _p;
public ProductCalculator(Product p) {
_p = p;
}
public double Calculate() {
// logic..
// calling repo
// calling services
// calling own class methods
return result;
}
//..
所以,問題是:是否ProductCalculator可以同時使用ProductRepository和ProductService? 或者我走得更遠:這是正確設計的域名?
服務可以使用他自己的方法來解決任務嗎?即時標題將產品計算器更改爲服務,但我不知道這是否正確。我只是問,在我看來,不。
問候
PS你有鏈接到一個開源項目(例如,在github),值得關注一下他們的域模型?