Hell code refactoring!
I inhirite a Java application that was written 15 years ago with millions lines of code
The code has many problems, including some very basic stuff like comparing object using ==. But somehow, it works and the company keeps using it
The problem we are facing is the code doesn't support debugging. ALL of the methods have very limited number of variables. The coders writting something like this all over places
if(getA().getB().getC().getD().getE().getM().equals(getA().getB().getC().getD().getE().getN()){
getA().getB().getC().getD().getE().getM().setZ(getA().getB().getC().getD().getE().getN().getZ());
}
int num = getA().getB().getC().getD().getE().getM().getList().size();
for(int i = 0; i<num; i++){
getA().getB().getC().getD().getE().getM().getList().get(i).setSomething();;
}
It is unbelievable but it is real. Some of them have more than 10 get() on the same line
I try to refactor it, adding local variables into the methods, so we can resuse the objects instead of using lines of get()
It also help debugging the code possible because there are many recursive calls plus the above style make it almost impossible now. Whenever something happens, it took me days to figure out what is wrong
I am going to break the get() chains but since the code base is huge, I don't know if we have some tools availble.
If someone has solved similar problem, please give me some advice.
Thank you very much