Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visualizing your code's architecture

Each weekend I'm coding on a personal project which over time has reached a certain complexity by now, where I have sequences of different functions that take my input, that I save in some class objects, chop it up, process it and then finally output it.
Since I make large breaks between coding sessions I usually forget the precise structure of my code. Therefore, each time I have a bug, I have to re-familiarize myself with how the input data flows through my code, how inside some module that provides functionality things are organized etc.

I'm not sure if this is due to bad code structure of my software, or simply inherent complexity.

Is there a tool that, given the source code, visually shows me how the "architecture" of my code, i.e. how the classes methods and functions all work together?

Ideally this would also help me understand code other people wrote faster, to get quickly an overview how the individual code pieces interact.

(I'm coding in Python with Pycharm, if that helps you.)

like image 979
l7ll7 Avatar asked Apr 04 '18 09:04

l7ll7


People also ask

How do you use code graphs?

Press Alt+C to find callers / included files / functions using the variable. Press Alt+V to find callees / files including this file / used variables. Some callees may not be found by pressing Alt+V . In these cases, place the cursor on those callees and press Alt+H , then they will be added to Code Graph.


1 Answers

I am afraid that there is no perfect tool for comprehensive visualizing your program architecture and its control flow, you should keep them in your head and make your software architecture clean, uniform and predictable. However there are some tools that can help you.

In Pycharm you can:

  • view structure and hierarchy of the source code

  • view UML diagram of your classes.

There is also the pycallgraph2 Python module that can create call graph visualizations for Python applications. (This is a maintained fork of the discontinued pycallgraph Python module)

And there is Codimension IDE that has Python code visualization feature

like image 148
SergeyLebedev Avatar answered Oct 08 '22 06:10

SergeyLebedev