r/java • u/kgilpin72 • Mar 23 '21
Visualize the architecture of your Java app, in VS Code, in 2 ¹/₂ minutes
9
u/Fireche Mar 23 '21
What would you say is the advantage of this solution over a class diagram?
19
u/kgilpin72 Mar 23 '21 edited Mar 23 '21
Hi, good question. There are a few advantages of the AppMap approach. One is that it shows the flow of information, rather than class hierarchy. Class hierarchy is pretty easily obtainable from static analysis, but execution flow information is not. You will also find HTTP server requests and SQL in AppMaps, which you will not find in class diagrams. Furthermore, with AppMaps you can drill down into a Trace view which shows parameter values, return values, SQL, status codes, exceptions, etc all recorded from program execution. So, AppMap combines low level and high level information, and links it all together. And it shows how the code handles requests, how key functions such as authentication are performed, and how incoming requests affect the database and external services (like S3 and other web and cloud services).
Here’s a 30 second video that goes into these capabilities a little more in depth: https://www.loom.com/share/fafb02fe69024c4f93ece3d7a1d57f18
Hope this helps, and thanks for the question!
3
u/Bone_charmer Mar 23 '21
Why should I use it ?
What tasks does it solve?
13
u/kgilpin72 Mar 23 '21
There are several jobs for which AppMap is very useful:
Orienting to unfamiliar code. You can use it to see what APIs are used, what SQL, what packages and code, and how they fit together. You see this in the context of a specific use case, not just a huge diagram that covers all scenarios, 99% of which you don't care about. And it's never out of date, because it's generated directly from running the code (e.g. test cases).
When you want to take a top-down view of the code, for finding and fixing a bug. Similarly for starting with SQL and then working your way back up the code tree.
For preparing a pull request. You can see the behavior of the code reflected to you, and you can see how it really works (as opposed to how you imagined that it works). You can evaluate if this design is clear and sensible, and you can iterate your design until it feels right.
Similarly, for reviewing PRs. AppMaps will show you how the code works, so that you don't have to try and imagine how it works by reading it. That frees your brain function to operate on a higher level, and consider new ways that the code might be improved. Or look for flaws in the design that could cause it to be slow, fragile, or vulnerable.
27
u/Electrical-Dream-190 Mar 23 '21
Do we have any chanche to se this extension in IntelliJ in near future ?
2
28
4
Mar 23 '21
At first I was skeptical and thought why not use IntelliJ's Diagrams but after reading your other replies I've changed my mind. Hope it's released for IntelliJ soon, great work!
1
u/MR_GABARISE Mar 24 '21
Since you're commited to open source, is this a good candidate for integration with SourceTrail?
2
u/kgilpin72 Mar 24 '21
I haven’t used SourceTrail. What would the integration look like?
1
u/MR_GABARISE Mar 24 '21
From what I read you'd have to go through their "extension" API.
The usage examples in the readme look pretty neat.
1
5
u/maxandersen Mar 24 '21
nice and I notice you can run this using jbang too :)
`jbang --javaagent=https://github.com/applandinc/appmap-java/releases/download/v1.0.3/appmap-1.0.3.jar ...`
but seem it does not trigger recording...must it be done via Tests?