TL;DR:
When dealing with code that is not yours, what are the most helpful techniques you employ to analyze, maintain and refactor that code, especially if it's in a very poor state when you encounter it?
Curious as to what thoughts people have here in terms of having to do mass-refactorings. I have inherited a pretty rotten codebase. While it worked OK at the time I took it over, it is absolutely rife with coding sins. Some of the stuff you hear people notoriously made fun of online for because it is just so obviously bad. To make things worse, the previous coder is not available (we did not part on amicable terms) and the codebase was horribly "documented". Because its so poorly written, it's often hard to ascertain what something does without spending a lot of time analyzing it, and then weighing out what the unexpected consequences might be of rewriting it.
While it's a great opportunity to get some experience in for refactoring and cleaning code, I'd love to know if anyone here has had to develop any specific techniques for doing so. In preparation I read a bit of "Working Effectively with Legacy Code" by Michael Feathers, "Agile Software Development" by Robert C. Martin, and some online stuff. I also switched from VS Code to Rider which has really helped with giving me a consistent IDE that I can refactor reliably in with its tools. Beyond that, though, it seems the best methodology for refactoring is to just take small, incremental steps toward your goal. Feather's book seems to have some decent techniques but I think they are situational and mostly a set of guidelines to follow that will not fit every problem you have, assuming you have solved some of the more basic issues. Without simply spending time with it and gaining experience slowly, it seems to simply just be a time consuming task that there is no easy solution for.