Is this a proper implementation of n-layer architecture?

前端 未结 4 2000
一生所求
一生所求 2021-02-06 17:52

I have been learning C# for the last year or so and trying to incorporate best practices along the way. Between StackOverflow and other web resources, I thought I was on the ri

4条回答
  •  南笙
    南笙 (楼主)
    2021-02-06 18:05

    Cade has a good explination. In order to avoid the Anemic domain model some things you could consider doing:

    • make the DTO object your domain object (just call it "Product")
    • IsValidProductId could then be on the Product, and when the setter is called you could verify that it is valid, and throw if it is not
    • implement some sort of rules about the Name
    • if there are any other objects that interact with Product we could have more interesting things to talk about

提交回复
热议问题