You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+31-5Lines changed: 31 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -30,9 +30,38 @@ A strongly connected component is a sub-graph where a path exists between any tw
30
30
31
31
Use the context menu to copy the related code elements to the explorer graph for further investigation.
32
32
33
+

34
+
35
+
36
+
37
+
### **Why Look for Cycles?**
38
+
39
+
More than 50 years ago, in his often-cited paper "On the Criteria to Be Used in Decomposing Systems into Modules," David Parnas suggested organizing software hierarchically, keeping the modules "loop-free." Similarly, Robert C. Martin's Acyclic Dependency Principle pushes in the same direction.
40
+
41
+
This idea of having cycle-free modules is quite intuitive. Let's look at an example outside the software world: Imagine a project plan with two tasks, A and B, depending on each other, forming a cycle. How would you tackle these tasks? You'd have to do them together as a whole. It's similar in software. If there are cycles in the area you want to change, you might end up reading and understanding all the classes involved in the cycle. Changes can easily have side effects in unexpected areas. Consequently, a software system with circular dependencies is more difficult to maintain.
42
+
43
+
The preference for hierarchical structures in software isn't arbitrary. It's deeply rooted in how our brains process information:
44
+
45
+
1. Research in cognitive psychology has consistently shown that the human brain understands and processes hierarchical structures more easily than non-hierarchical or cyclic ones.
46
+
2. We naturally organize our knowledge hierarchically, which makes hierarchical code structures more intuitive to understand and remember.
47
+
48
+
Therefore, I see this advice as a timeless principle. While studies on how we learn and understand things may be old, they will never be outdated. The main tool we use to write software, our brain, will be the same tomorrow.
49
+
50
+
There are other attributes associated with hierarchical and cycle-free systems like testability, maintainability, etc. For me, the matter of understanding the system is the most important. I doubt that you can have maintainability in a hard-to-understand codebase.
51
+
52
+
**C# Code Analyst** helps you identify cycles in your code, offering a higher-level perspective on your code structure. By using this tool, you can:
53
+
54
+
- Gain insights into your code's organization that might not be apparent when working at the detailed level.
55
+
- Identify opportunities to refactor and improve your code's structure.
56
+
- Enhance the overall readability and maintainability of your codebase.
57
+
58
+
Remember, the goal isn't to eliminate every cycle but to be aware of your code's structure and make informed decisions about its organization. Some cycles may be intended, even some design patterns use them. By focusing on readability, you're investing in code that's not just functional, but also easier to understand, maintain, and evolve.
59
+
60
+
**In general, I think it's a good guideline to keep your software system free of cycles at the namespace level.**
61
+
33
62
## Dependency Structure Matrix (DSM)
34
63
35
-
**Not tested.**
64
+
**Not tested!**
36
65
37
66
A **DSM** (Dependency Structure Matrix) displays all the dependencies in your codebase in a condensed matrix. It may take some time to become familiar with it. For further explanation, you can visit https://dsmsuite.github.io/.
- There is a bug in the graph layout package that may cause the application to crash when you collapse sub-graphs.
53
-
- The graph package does not support multiple edges between the same code elements when sub-graphs are used; the edges are combined in this case.
54
-
- Collapsing sub-graphs does not remap the incoming dependencies to the collapsed sub-graph. To observe this, export the graph to DGML and open it in Visual Studio.
81
+
- The graph layout package does not support multiple edges between the same code elements when sub-graphs are used; the edges are combined in this case.
55
82
- The directory structure of the source code is completely ignored, so keep this in mind when searching for cycles.
56
83
- The tree view search may be very slow, depending on the result.
57
84
- Source locations are not extracted for all dependencies, only the ones that are easy to extract.
58
85
- External code is ignored.
59
-
60
86
- The C# Roslyn part only focuses on the most common language constructs. However, even the supported language constructs may be incomplete. For any known unsupported syntax, refer to [Documentation\Uncovered C# Syntax.md](Documentation/Uncovered C# Syntax.md)
0 commit comments