Circular Dependencies

I have another library dependencies question. Let’s say I have the following library structure:

-- LibFolder
  |-- LIB_A
  |-- LIB_B

Each libray is dependent to each other, means LIB_A is dependent on LIB_B, but LIB_B is also dependent to LIB_A.
LIB_A library.json:

{
    "name": "LIB_A",
    "version": "0.0.1",
    "description": "This library is used as an example.",
    "frameworks": [
        "chiisai"
    ],
    "dependencies": {
	"LIB_B": "file://LibFolder/LIB_B"
    }
}

LIB_B library.json:

{
    "name": "LIB_B",
    "version": "0.0.1",
    "description": "This library is used as an example.",
    "frameworks": [
        "chiisai"
    ],
    "dependencies": {
	"LIB_A": "file://LibFolder/LIB_A"
    }
}

The issue occurs when I now install one of the two libraries with the pkg install command. It is adding every instance twice.


Is this really the indendent behaviour? In my eyes, it should be possible when adding LIB_A, LIB_B should also be added, and also the other way round when adding LIB_B. I know that I could theoretically combine both libraries, but I want to keep them separated.

Is this a theoretical question or is the problem real?
I don’t have a solution to your problem, but I would like to give you my opinion:

In this case, I would say you did something wrong as a software designer.

According to Uncle “Clean-Code” Bob (Robert C. Martin): “Extract, extract, extract!”

A circular dependency is not only bad for the compilation process but also bad in terms of maintenance and increased error-proneness.
Your project will suffer in the long run.
The productivity of your team will decrease.

This is just my opinion. :innocent:

1 Like