This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
Is there a tool for printing out a namespace dependency tree? Looking to refactor our code base and want to idea which pieces we easily pull out into sub-projects.
(It feels like something that could easily be built but I figured I'd ask before I reinvent that wheel)
@seancorfield: If it is Java classes files there are many. I have used DependencyFinder (http://depfind.sourceforge.net/). IntelliJ is also really good (although it may work with sources files). Of course none of this helps with ClojureScript. One of the reasons DependencyFinder is good IMO because it goes off Robert C. Martin's metrics, and it is easy to find the recursive namespace dependencies which are the worst thing.
They all become class files though, these tools would not know how the classes were produced, DependencyFinder anyway.
No, that's not what I want. I want to analyze source code for the namespaces that are required to create a tree.
Worst case, I can write something to parse the code, read the
:require forms, and build a tree. I was just hoping something already existed.
It analyses class files but what it gives you is namespaces and how they are related to one another (i.e. Java imports).
Yep - it basically does what would be called 'package dependencies' in the Java world, which are 'namespace dependencies' in this world.
I'll go look in
tools.namespace -- I suspect it knows how to build a tree since it can do a reload in namespace dependency order.
(fwiw, we don't AOT our Clojure so there are no class files on disk and we don't create a JAR either)
These tools give you your DAG - a neat diagram so you can understand your design. It is fairly OO stuff but my thinking it that it still applies.
Hence my wanting something either source-based or that I can use from the REPL fairly easily...
We have about 30,000 lines of Clojure in production and we're moving from Leiningen to Boot so we have an opportunity to move away from a rigid project-based structure to something more modular (one of the things that Boot is intended to help with).
I do a special build to exclude 'not done by us' library dependencies, so the DAG (directed acyclical graph) output is concentrating on only the actual production code we wrote. But I haven't needed to do this stuff with Clojure yet, and DependencyFinder is pretty old now. It is a very interesting and important area - good to keep tabs esp on recursive namespace dependencies (and uncle Bob's metrics) while any largish project is ongoing. However that is all my old OO thinking. I'm not so sure the metrics would be so important in a functional design.
Yeah, I used to do a lot of OOP metrics and source code analysis work back in the early/mid-90's. I wrote a C++ source code analyzer that did a whole bunch of stuff around coupling and coherence. It's been a long time so my OOP metrics memory is probably a bit rusty now...
https://shaunlebron.github.io/parinfer/ wow that looks seriously interesting to me as a beginner
I guess I'll need to take it apart to produce just a text tree... I don't really want a picture since that's not so easy to manipulate... but it should get me started!
I found that and a similar one a couple of months back by looking for namespace dependency lein 😉
Guess I should build a Boot task for it since that's the way I'm going these days...
Much appreciated @meikemertsch -- I have a Boot task now that produces a first cut text dependency graph of my code! Thank you sir!
@malch: produces a picture like lein-ns-graph. Not easy to manipulate. But thank you anyway.