how to avoid circular dependencies here

后端 未结 4 1051
悲哀的现实
悲哀的现实 2020-12-14 09:07

Is there a way to avoid circular dependencies, other than mixing modules, in a arrangement like this(it is a chess application)

Long description:

4条回答
  •  情书的邮戳
    2020-12-14 09:49

    I'm gonna stick my hand up here and say... IMHO you may have over-designed this.

    Why does a piece need to have knowledge of the player? A piece in chess is either black or white, irrespective of who is controlling (playing) it.

    You mention "player module" and "piece module" - why are they separate modules? Why aren't they just data classes (domain objects) together in the same module?

    If i have over analyzed this or failed to understand how you have constructed your game then by all means ignore what i said. OTOH maybe i did read things right?

提交回复
热议问题