admin-announcements

Announcements from the Clojurians Admin Team (@U11BV7MTK @U077BEWNQ @U050TNB9F @U0ETXRFEW @U04V70XH6 @U8MJBRSR5 and others)
seancorfield 2015-12-24T04:41:52.002387Z

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.

seancorfield 2015-12-24T04:42:38.002388Z

(It feels like something that could easily be built but I figured I'd ask before I reinvent that wheel)

cjmurphy 2015-12-24T04:50:31.002389Z

@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.

seancorfield 2015-12-24T04:51:05.002390Z

Not JAR dependencies. Source file dependencies in Clojure.

cjmurphy 2015-12-24T04:52:28.002391Z

They all become class files though, these tools would not know how the classes were produced, DependencyFinder anyway.

seancorfield 2015-12-24T04:53:09.002392Z

No, that's not what I want. I want to analyze source code for the namespaces that are required to create a tree.

seancorfield 2015-12-24T04:54:21.002393Z

Worst case, I can write something to parse the code, read the ns / :require forms, and build a tree. I was just hoping something already existed.

cjmurphy 2015-12-24T04:54:55.002394Z

It analyses class files but what it gives you is namespaces and how they are related to one another (i.e. Java imports).

seancorfield 2015-12-24T04:55:14.002395Z

As I said, not what I want.

seancorfield 2015-12-24T04:55:25.002396Z

I don't care about dependencies outside the source tree.

seancorfield 2015-12-24T04:55:54.002397Z

I only care about internal dependencies in the source code of one project.

cjmurphy 2015-12-24T04:56:33.002398Z

Yep - it basically does what would be called 'package dependencies' in the Java world, which are 'namespace dependencies' in this world.

seancorfield 2015-12-24T04:57:18.002399Z

You're not being much help but I appreciate the effort :simple_smile:

cjmurphy 2015-12-24T04:57:44.002400Z

np

seancorfield 2015-12-24T04:58:49.002401Z

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.

seancorfield 2015-12-24T04:59:57.002402Z

Hmm, yeah, dependency graph looks promising.

seancorfield 2015-12-24T05:00:37.002403Z

(fwiw, we don't AOT our Clojure so there are no class files on disk and we don't create a JAR either)

cjmurphy 2015-12-24T05:00:44.002404Z

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.

cjmurphy 2015-12-24T05:02:04.002405Z

Oh no class files. That no good at all! šŸ˜ž

seancorfield 2015-12-24T05:05:38.002406Z

Hence my wanting something either source-based or that I can use from the REPL fairly easily... :simple_smile:

seancorfield 2015-12-24T05:06:52.002407Z

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).

cjmurphy 2015-12-24T05:13:01.002408Z

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.

seancorfield 2015-12-24T05:21:46.002410Z

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...

2015-12-24T05:22:24.002411Z

@seancorfield: this one is pretty crude but maybe you can start there: https://github.com/hilverd/lein-ns-dep-graph is that the kind of tool you're looking for?

2015-12-24T05:22:28.002413Z

https://shaunlebron.github.io/parinfer/ wow that looks seriously interesting to me as a beginner

seancorfield 2015-12-24T05:22:50.002414Z

@meikemertsch: Great! Sounds like it'll save me a bunch of work...

seancorfield 2015-12-24T05:24:42.002415Z

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!

2015-12-24T05:26:11.002416Z

I found that and a similar one a couple of months back by looking for namespace dependency lein šŸ˜‰

seancorfield 2015-12-24T05:27:09.002417Z

Guess I should build a Boot task for it since that's the way I'm going these days...

seancorfield 2015-12-24T05:49:06.002419Z

Much appreciated @meikemertsch -- I have a Boot task now that produces a first cut text dependency graph of my code! Thank you sir!

2015-12-24T07:13:06.002421Z

Sir? ;) My pleasure

malch 2015-12-24T07:25:52.002422Z

@seancorfield: You may want to take a look here: https://github.com/Hendrick/boot-medusa

seancorfield 2015-12-24T07:28:28.002424Z

@malch: produces a picture like lein-ns-graph. Not easy to manipulate. But thank you anyway.

seancorfield 2015-12-24T07:28:49.002425Z

Good to know that I'm not crazy in wanting a tool like this!

malch 2015-12-24T07:29:06.002426Z

Just for your information, np šŸ˜‰

malch 2015-12-24T07:30:51.002427Z

@seancorfield: Also Iā€™m using https://github.com/greglook/lein-hiera in lein world