Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
822 views
in Technique[技术] by (71.8m points)

intellij idea - Java layer separation circular dependencies between modules

I'm making an assignment for school and I need to implement layer separation in my program. I made a litte game called Space Invaders. It works but when I try to separate things into modules I keep getting the message in IntelliJ.

Adding dependency on module business will introduce circular depency between modules audio and business

I also made an attempt to separate the dataaccess layer with the business layer. After fighting for several hours I have it working. But had to delete the module-info.java. Which isn't a good thing. I must be overlooking something. To make it a bit visual :)

A first start with my layer separation: [Layer separation drawing] [1]: https://i.stack.imgur.com/wT9FC.png

[Classdiagram] [2]: https://i.stack.imgur.com/imYI3.png

And of course the code :) It a bit too big to post here, so here is the link to GIT.

https://github.com/Koffiemolen/SpaceInvaders.git

I try to separate dataccess HighscoreStore and the SoundFactory. SoundFactory is in de the audio module.

If I'm using terms incorrect please let me know. I'm still learning ;-)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Your circular dependency is between business and dataaccess - they depend on each other typically your data access and audio shall depend on nothing, and business gets dependency to both.

Dependency to JUnit shall have scope of test.

And while we are at it, use maven or even better gradle - this would be cool and portable way to build project. and IDEA just grabs those project models and uses them natively


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...