Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intellij dependency viewer and package cyclic dependency

All my programming life I have been thinking that the cyclic dependency is the following:
GIVEN

  • package1
  • package2
    • subpackage2
  • package3

IF

  1. Class from package1 references class from package2
  2. Class from package2 references class from package3
  3. Class from package3 references class from package1

THEN
Project contains cyclic dependency package1 > package2 > package3 > package1.

This was a pretty huge surprise when Intellij's dependency viewer told me, that:

IF

  1. Class from package1 references class from package2
  2. Class from subpackage2 references class from package3
  3. Class from package3 references class from package1

THEN
Project contains cyclic dependency package1 > package2 > package3 > package1.

Could anybody, please, explain me what is the strict definition for cyclic dependency and why does Intellij show such weird results? Thanks.

like image 681
mr.nothing Avatar asked Feb 26 '16 14:02

mr.nothing


1 Answers

The dependencies are transitive, so by virtue of depending on subpackage2 which in turn depends on package3, package2 itself depends on package3, thus forming the exact same graph as example 1. I'm more surprised other tools don't see it as a circle, as IntelliJ is correct here.

like image 114
kaqqao Avatar answered Sep 27 '22 21:09

kaqqao