Patrick (patrickwonders) wrote,
Patrick
patrickwonders

Visualizing Code

Inspired by a recent post by jerronimo, I threw together some code to visualize the interconnections of code.

It's a pretty straightforward representation. Each node is a function (or macro). There is a spring between two nodes if one function calls the other. There is also a repulsive force between functions so that they don't get too close together.

I'd like to make the rest length of a spring shorter between foo() and bar() if foo() calls bar() a bunch of times. But, that's not implemented yet.

I also need to incorporate some way to move your viewpoint a bit because somehow or other, the equillibrium between the repulsive force and the spring tension isn't really where I expect it, so lots of stuff grows right off the edges of the window. Actually, what I really need to do is figure out why my spring system is so unstable. I damped the motion and things got a little better, but things still grow more than I think they should.

I'd also like to add in labelling and/or color coding the vertices.

Anyhow, here are some shots. This first one is a vector-math library that has eleven functions and one macro.

visualization of vec-math library

This next one shows the code that does the analysis and display. On the left is how the code looked yesterday. On the right is how the code looks now.

visualization of vis code

All of the related code is now hosted on GitHub. Here is the code base. It requires that the following libraries be available somewhere that ASDF can find them:

Tags: code, lisp
Subscribe
  • Post a new comment

    Error

    default userpic

    Your reply will be screened

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 5 comments