This application was written without any knowledge of design principles (SOLID) by the previous developer. The most critical issue of the app is that it has god class with lots and lots of switch statements. This ill-advised structure makes it hard to maintain the app. Of course, there is no unit testing at all.
First on switch statements, I found there are two main potential classes that varies over the application. So I will try to first construct those two classes and move the corresponding code to the classes from the god class. Is this a right way? What is a good process to attack this issue?
BYW, I have the book “Working Effectively with Legacy Code”. So you can suggest which part of the book I have to read for this too 🙂
Switches are an obvious refactor target. But there could be others. You give uslittle to go on.
I often spend a great deal of time massaging the code, rewriting it such that I can change the type used by commenting/uncommenting a few lines.
For a swich on an enum, it can be useful to define a struct that contains one member: the enum value, and has an implicit conversion to the enum value. Using typedefs or macro, you can make sure that your new type is passed around in stead of the enum. If that has undesired side effecs, revert, fix the implementation, and try to use yournew type.
Next, move the switch code to a member function of the new type, one switch at a time.
If unit tests are required in the process is up to you.