Code path-finding and architectural dependency enforcement

 One of the development tools I would like is a code pathfinder.

I don’t mean something that can jump to the definition of a function from somewhere it is called, I have that already in VIM using exuberant ctags. I can even use that to find the usages of a function from its declaration, what I want is more. Something deeper.

Given two functions, an answer to the question “Is there a call path from one to the other?” and then visibility on some of the shortest paths through the call stack between those functions.

There are a few other graph-based analysis tools I want to build to aid in development. When working on large projects there are some important architectural constraints that start to become more important. Especially when working on a larger team these ideals and ideas that the original developer might try to put into the architecture of a new component get diluted down.

Once diluted, things that should make the code easier to read, such as one point of entry and one point of exit for functions breaks.

The single point of exit for a function is only useful for reading through the code if you can guarantee that there is only one place the function exits otherwise it becomes an assumption that will inevitably be the source of bugs. Clearly, you can add simple CI steps if as a team it is decided that things such as there should only be one point of exit are decided upon.

My personal preference is for functions to be short enough so that the single exit pattern isn’t needed.

What I want to be able to do though, is to look at enforcing things at a higher level. If one module shouldn’t be imported by another because it should be dependency-clean then it would be nice to have this enforced.

If working on an existing codebase I believe you can still progress with dependency management. You can add CI steps that enforce that new dependencies are not added to code that is supposed to be dependency-free. That stops the task of disentangling the code from becoming a hydra.


Popular posts from this blog

An exploration in number systems

Structural engineering with cardboard