2
Answers

Identifiers visibility in the program text.

Photo of Mariusz Postol

Mariusz Postol

Jul 31
480
1

We must talk about projects and project dependencies because visibility in other projects depends on visibility (access) modifiers and dependencies between projects. I think that an interesting question is what is the reason that there must not be bidirectional references between projects?

I am talking about MVS2022 projects. After trying to add a backward reference I am getting the message as follows.

 

The next question is why circular dependencies are impossible or inappropriate.

Answers (2)

1
Photo of Mariusz Postol
396 3.9k 57.7k Aug 02

@Jayraj Chhaya - many thanks for your answer, but you said " This scenario can lead to ambiguity" - this scenario is well-known and widely accepted for ages as the recurrence. Hence, why does the recurrence be good when used inside the project but bad in case definitions are spread around many projects?
 
Next: "Visual Studio ensures a clear and manageable project structure" - I assume that project means solution in terms of VS. How to prove that by removing circular references our solution will be more clear and manageable. 

I believe the answer must be something else. It is not only best practice rules that in this particular point are dispared with the IT practice and theory.

Rdgs Mariusz

1
Photo of Jayraj Chhaya
307 6k 96.4k Aug 02

Circular dependencies, where two projects reference each other, are disallowed due to the risk of creating an infinite loop during compilation. This scenario can lead to ambiguity and make it challenging for the compiler to resolve dependencies correctly. By enforcing a unidirectional reference flow, Visual Studio ensures a clear and manageable project structure, preventing issues like compilation errors, infinite loops, and potential conflicts in resolving dependencies. This restriction promotes a more organized and maintainable codebase, enhancing the overall stability and efficiency of the development process.