DDD Entities making use of Services

后端 未结 5 1391
生来不讨喜
生来不讨喜 2021-02-01 08:18

I have an application that I\'m trying to build with at least a nominally DDD-type domain model, and am struggling with a certain piece.

My entity has some business logi

5条回答
  •  半阙折子戏
    2021-02-01 09:07

    This question is actually an example of a discussion that is in the book "Clean Code" (pp 96-97). The underlying question is whether or not to use a procedural approach or a object oriented approach. Hope I'm not in violation repeating a couple parts here, but here is what Bob Martin states for guidance:

    Procedural code (code using data structures) makes it easy to add new functions without changing the existing data structures. OO code, on the other hand, makes it easy to add new classes without changing existing functions.

    The compliment is also true:

    Procedural code makes it hard to add new data structures because all the functions must change. OO code makes it hard to add new functions because all the classes must change.

    My understanding that a DDD "Value type" would be what Bob Martin calls a data structure.

    Hope this helps and doesn't just add to the noise :)

提交回复
热议问题