I am working on a huge code base (more than a million lines of code with a sophisticated architecture) written in C++ over the span of a couple of decades. The task on which I'm working at this point is understanding the use of a specific class whose functionality is unknown to almost every developer of the team. The reason? Because as I mentioned the code has been in development for decades and it's been through major changes, upgrades etc. etc. so you can imagine it may get messy when you have a million lines of code being developed by hundreds of developers.
I need to analyse and understand the structure and utility of a file called CLASS_inc.hxx
.
Here are the details of my challenge:
A class called A_CLASS
is declared in the header file CLASS_inc.hxx
with all it's member functions. The members of this class are called in a couple of different parts of the code using scope resolution CLASS::member_function
(well it's more complicated than that but I'm simplifying, you can also see a simplified snippet of the code down below). I could understand that some of the member functions are completely useless, I simply ran the command grep -rwin member_function
in src
of the code which returned no trace of the memeber_function
anywhere in the code, because it is simply declared but never called in any corner of the code. So I deleted these useless member_functions
compiled my code and ran the Test_Cases (there is a huge test base in the code) and all tests passed without problem. Now here comes the challenging part, the remaining member_functions
constituting around 70% of the original member_functions
are called in other functions in the code and I have no idea how to understand what they do!!!
So is there any methodology or tool or strategy in such cases to attack such problems?
For the information of those of you who might suggest "read the document", "read the comments in the code", "try to understand from the name of the member functions or class" I should say that there is absolutely no comment in the code, the name of the variables, classes and functions don't suggest anything (for instance one member function is called LADP).
Here is a simplified snippet of the code just to give you an idea, this is our CLASS_inc.hxx
#ifndef CLASS_inc_included
#define CLASS_inc_included
#include "blabla1.hxx"
#include "blabla2.hxx"
namespace CLASS_inc
// COMMON CLASS : VARIOUS WORK VARIABLES
class A_CLASS : public A_Base
{
public:
A_CLASS();
void constructor();
~A_CLASS();
void destructor()
{
delete[] _container_of_double;
_container_of_double = NULL;
}
const double& LADP_get() const
{
return *_LADP;
}
const double& LADC_get() const
{
return *_LADC;
}
.
.
.
.
.
private:
double* _container_of_double;
double* _LADP;
double* _LADC;
.
.
.
};
extern A_CLASS* _CLASS;
.
.
.
And then the members of the above class somewhere in the code in other functions are called as the following example:
&CLASS_inc::CLASS().LADP_set()
The above snippets are very simplified depiction of the code but the pattern is the same.
I'm working on unbuntu 20.04 and the code is in C++.