I have a project (related to graph algorithms). It is written by someone else.
The code is horrible:
- public fields, no getters/setters
- huge methods, all public
- some classes have over 20 fields
- some classes have over 5 constructors (which are also huge)
- some of those constructors just leave many fields
null
(so I can’t make some fields final, because then every second constructor signals errors) - methods and classes rely on each other in both directions
I have to rewrite this into a clean and understandable API.
Problem is: I myself don’t understand anything in this code.
Please give me hints on analyzing and understanding such code.
I was thinking, perhaps, there are tools which perform static code analysis
and give me call graphs and things like this.
Oh dear 🙂 I envy you and not at the same time..ok let’s take one thing at a time. Some of these things you can tackle yourself before you set a code analyzing tool loose at it. This way you will gain a better understanding and be able to proceed much further than with a simple tool
it is required and use composition instead via interfaces where applicable
Best of luck we are here to help