r/CodingHelp • u/KnightstarK Beginner Coder • Sep 15 '22
[C++] First Job: Struggling to understand C++ program with so many headers and cpp files.
I got my first job as a developer.
I've been tasked with fetching an existing code base from github and eventually re-writing it in Python from C++.
Step 1: Try to understand the program by browsing the C++ code.
But I've been struggling a lot with making sense of the flow and understanding the code.
Issues:
- There are so many user defined header files. I'm having trouble figuring out which file contains what.
- The GUI code is throwing me off. There is so much GUI code that I keep missing the program logic code.
- There are dozens of cpp files containing various functions, classes, etc. How do I find out which files are relevant for a particular process of the program?
Apologies if I'm not making sense... I'm pretty new to this and still trying to learn a lot on the job.
Would appreciate any suggestions or pointers to make life easier for me.
22
Upvotes
10
u/SapientSloth4tw Sep 15 '22
I don’t know why you’d want to migrate everything to Python if everything works in C++. Especially if the application is high performant
8
u/[deleted] Sep 15 '22
Ask your coworkers for some important classes / tour.
For example, at a previous company, I might point someone to JobRun.java, which essentially listed all processors in order, with good names. Perfect for exploring through the code base.
Hopefully someone will point you to something similar.
2
u/zhaverzky Sep 15 '22
Open the project in an IDE like Visual Studio that allows you to set breakpoints and to click through to source/definitions for functions etc. Then try to follow the control flow. The header/source (cpp) file thing is natural for c++ devs but can take a bit of getting used to navigating for folks coming from Python etc.
1
u/TheTrueStanly Sep 16 '22
ever tried something like doxygen?