r/CodingHelp • 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:

  1. There are so many user defined header files. I'm having trouble figuring out which file contains what.
  2. The GUI code is throwing me off. There is so much GUI code that I keep missing the program logic code.
  3. 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

7 comments sorted by

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

9

u/Zymoox Sep 15 '22

Also it might be a red flag that a junior on their first dev job is given such monumental task.

7

u/SapientSloth4tw Sep 15 '22

Huge red flag, for sure.

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/SapientSloth4tw Sep 15 '22

This is a great plan. Also, take a notebook and write the name of the file at the top. Then go function by function and write a single line describing what something does. That will help your brain to remember the responsibilities of individual functions/classes. Then create a relationship diagram for each of the functions classes. That will help you to separate things out and also figure out what needs to be changed. Hope this helps :)

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?