Best way to understand huge code
What is the best way to understand the flow in a huge file/module. For example a huge java file with many flows and functions getting called all over the place. I try to read through and understand but its hard to keep so much in my head so I end up doubling back and forth and getting confused. Do you guys use any techniques. Or any way to take notes or draw diagrams?
Jordon Everett
Stealth
a year ago
Ask chat gpt. Seriously...have done this
There also this LLM which is integrated with VS code env https://cursor.sh/ which works well. This is godsend if your office don't allow chatGPT
See more comments
Jordon Hyrum
Stealth
a year ago
Understand the product flow.
1. Ask engineers which component is for which functionality.
2. Then come to that component and see the flow and functions which are there and also see from where they are being imported.
For backend
1.Create a map of DB tables
2.Go to the model views and controllers if they exist.
3.understand the dependency.
4.also see what queries are running.
5. What kind of cron jobs or Background services are there.
I have limited experience of 1.5 years as a Frontend engineer, so I can say this as an overview.
Hope you understood.
And if there's a. Function you can't understand then copy paste in gpt and ask what it does and how it is working, explain line by line
These are good tips, will try them out. Except in my case for point number 1, there is no one to ask to because everyone was laid off π
Coy Carmden
Stealth
a year ago
Something you can try: go through the function flow, add a log at each function call with some variables. On running you can see the flow and mutations step by step. I work with react, so redux makes things much easier since it shows step wise states and diffs
Run the test cases OP ( I hope there are test cases for your repo ) . They will cover a lot of scenarios which will atleast help you understand the flow. Hi
Add a breakpoint where you think you can trigger the flow and check the call stack. Play around with it.